Thursday

Write a program to read a line of text and convert it into uppercase.

#include<stdio.h>
#include<conio.h>
#include<string.h>
C programvoid main()
{
 char string[100];
 printf("\nEnter any line of text in lowercase\n");
 gets(string);
 strupr(string);
 printf("\n Enterd text converted into uppercase\n");
 puts(string);
 getch();
 }

OR

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
 char string[100];
 int i;
 printf("\nEnter any line of text in lowercase\n");
 gets(string);
 for(i=0;string[i]!=0;i++)
 {
 if(string[i]>='a' && string[i]<='z')
 string[i]=string[i]-32;
 }
 printf("\n Enterd text converted into uppercase\n");
 puts(string);
 getch();
 }

No comments:

Post a Comment

Rahul-Notes