Skip to main content

Posts

Showing posts with the label c program to print each words in new line

String Programs In C Programming Asked In Interviews.

31) Sample C Program to accept a string and print each word in new line. # include <stdio.h> # include <conio.h> main( ) { char ch; clrscr( ); printf("Enter a string :"); while( ( ch = getchar( ) ) != '\n') { putchar(ch); if(ch == ' ') printf("\n"); } getch( ); } 32) Sample C Program to accept a string and count no of capital letters, no. of small letters and no. of special characters. # include <stdio.h> # include <conio.h> main( ) { char ch; int c = 0,s = 0,s1 = 0; clrscr( ); printf("Enter a string :"); while( ( ch = getchar( ) ) != '\n')   {      if(ch >= 'A' && ch >= 'Z')         c = c + 1;      else if(ch >= 'a' && ch >= 'z')         s = s + 1;      else         s1 = s1 + 1;   } printf("No. of capital letters are %d", c); printf("No. of small letters are %d", s); printf("N...