Completely Solved C, C++ Programs Assignment.




C Program to accept a string in lower case and print first character of each word in upper case

Filed Under:

Problem 96. C Program to accept a string in lower case and print first character of each word in upper case.
#include<conio.h>
#include<stdio.h>
main( )
{
char str1[80];
int length,i;
clrscr( );
printf(“enter a string; “);
length=getline(str1,80);
for(i=0;i<length;i++)
{
str1[0]-=32;
if(str1[i]= =’ ‘)
str1[i+1]-=32;
printf(“%c”.str1[i]);
}
getch();
}
int getline(char line [], int lim)
{
int i;
for(i=0;i<lim && ((line[i]=getchar( ))! =’n’);i++);
if(line[i]= =’n’)
line[i]=’�’;
return i;
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments