> Beginner in c programing and I need help with writing a program?

Beginner in c programing and I need help with writing a program?

Posted at: 2014-12-18 
Since it seems that the school has chosen a very poor book, you should go to the bookstore and find a better book. What is so strange is that not only has your school chosen such a poor book, the publisher of that book decided to publish that book. That means the publisher spend money on paper and ink and binding for a book that they thought no one would buy (because it's so poor).

Meanwhile, your assignment says that there would be input.

Normally, you would use a Scanner object to get the input. You probably already did that in your previous assignment.

So, start with reading in the string and just count ALL the characters and display the count.

Then use stepwise refinement.

That mean, this time, change the program to count ONLY the the letter "a".

So, take it one step at a time. Don't get overwhelmed by the whole assignment.

Do you think the school is getting a kickback from the publisher?

There are many ways to do it, but this will be basic and simple.

declare 4 int variables to represent the no. of spaces, digits, Upper, and lowercase characters.

initialize them all to zero.

declare a char variable ch.

Read each character of the input individually into a char.

Use a while loop and get char() to test for the end of the input string marked by the return "newline" character .

while ((ch = get char( ) ) != '\n') {}

inside the while loop check for the type of each character using if statements .

To check for a character type use the ASCII table integer values.

The whitespace character is value 32

Uppercase characters are in the range 65 - 90

lowercase chars are in the range 97 - 122

digits are in the range 48 - 57

which ever test the current character passes will increment that character type's variable by one.

Once the while loop encounters the return it will stop reading and the program will continue to the next operation which is to print out the results.

Your print statement will print each int variable of the different char types.

I like Gollum's approach but instead of checking for ascii uppercase, lowercase, digit, etc ranges you could do used library functions. Here are the functions with samples:

isupper: http://www.tutorialspoint.com/c_standard...

islower: http://www.tutorialspoint.com/c_standard...

isdigit: http://www.tutorialspoint.com/c_standard...

isspace: http://www.tutorialspoint.com/c_standard...

If above url's should render non-existent you can query google for isupper, islower, isdigit, and isspace ...

//Abbc56764***

#include
#include

int main(void){

int Ualeph=0,Laleph=0,Wspace=0,Digit=0;

char * sentence="Abbc56764 ";

int c=0;

while(*(sentence+c)!=0){

if (isspace(*(sentence+c))) Wspace++;

if (isupper(*(sentence+c))) Ualeph++;

if (islower(*(sentence+c))) Laleph++;

if (isdigit(*(sentence+c))) Digit++;

c++;

}

return 0;

}

im using notepad++ newest version

okay my teacher doesn't explain well so most of my knowledge is from the book

he gave us this assignment and Im completely lost in how to write it

If possible can someone please help me write it or explain to me what I need to write

please I would greatly appreciate it

here is what he wants

Write a complete program to counts the whitespace, the digits, the uppercase alphabetics and lowercase alphabetics in the input.

Example :Abbc56764***;;;;

There were one uppercase alphabets and three lower case alphabet and five digits and zero space.

now I know il learn this later on but he hasn't explain or even gone over how to writ a code like this and he wants use to do it without any knowledge of how to do it. please someone help