Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <ctype.h>//Standard library for Characters.
- void banner(void){ //Function to print out name and class
- printf("------------------------\n");
- printf("Malachi Sor\nCSCI 1110-01\n");
- printf("--------------------------\n");
- }
- int main(void) {
- banner();
- int counter =0;//counter will start at 0
- while(1){ //This will check if the character is true because 1 means true.
- char character;
- printf("\nEnter the character: ");
- for(;;){
- //Don't put the printf statment under the for loop or else it will Loop and input every single character you have put even though it is not S.
- scanf("%c",&character);//user input the phrase or word.
- if (character=='s'){//This will check if the user input is a lower case 's'.
- counter ++; //increment the counter by 1
- printf("th");
- }
- else if (character=='S'){// will check if the user input has the character 'S' as a capital.
- counter ++;//increments by 1
- printf("Th");
- }
- else { //If there are no S, then the word will just print itself out.
- printf("%c",character);
- counter++;
- }
- if (character=='.'){//checks if the user input has the period signifying the end of the loop and leading to the break.
- break;}// breaks out of the for loop into the while loop.
- }break;}//breaks out of the while loop and goes to the return 0.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment