C/C++ Program that will scan a character string passed as an argument & convert all lowercase characters into uppercase characters.
Program
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void convupper (char s[10]);
void main()
{
char str[10];
clrscr();
printf("Enter the string:");
scanf("%s",str);
convupper(str);
getch();
}
void convupper(char s[10])
{
int i;
for(i=0;i<10;i++)
if(islower (s[i]))
{
s[i]=toupper(s[i]);
}
printf("%s",s);
getch();
}
Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h"
2.) for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
No comments:
Post a Comment