Question: Can I get assistance in code added to this program that will print the total number of letters in the user entered string? Thanks #include
Can I get assistance in code added to this program that will print the total number of letters in the user entered string? Thanks
#include
//Function that displays string backward void backWard(char str[], int len) { int j;
//Iterating in backward direction for(j=len-1; j>=0; j--) { printf("%c", str[j]); } }
//Function that displays string vertical void vertical(char str[], int len) { int j;
//Iterating in vertical direction for(j=0; j //Function that displays string triangle void triangle(char str[], int len) { int i, j, k=0; for(i=1; str[k]!='\0'; i++) { //Iterating row wise for(j=1; j<=i&&str[k]!='\0'; j++) { printf("%c", str[k]); k++; } printf(" "); } } //Main function int main() { char str[100], ch; int len; //Iterate till user want to quit do { //Reading string from user printf(" Enter a string: "); gets(str); //Finding length len = strlen(str); //Display forward printf(" Displaying string in forward: "); puts(str); //Display backward printf(" Displaying string in backward: "); backWard(str, len); //Display vertical printf(" Displaying string in vertical: "); vertical(str, len); //Display triangle printf(" Displaying string in Triangle: "); triangle(str, len); //Prompting user for quit or re-run printf(" Do you want to quit? (y/n)"); scanf("%c", &ch); gets(str); }while(ch=='n'||ch=='N'); printf(" "); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
