Write a C function print_upper ( ) to prints its character argument in uppercase.
#include <stdio.h>
#include <conio.h>
void print_upper ( char str[] )
{
int i;
for ( i = 0; str[i] != '\0'; i++ )
{
if ( str[i] >= 'a' && str[i] <= 'z' )
{
str[i] = str[i] - 32;
}
}
}
void main ( )
{
char str[40];
clrscr ( );
printf("\n\n\n\t\t Enter a string..: "); gets(str);
print_upper ( str );
printf("\n\n\t\t The upper case string is..: %s",str);
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void print_upper ( char str[] )
{
int i;
for ( i = 0; str[i] != '\0'; i++ )
{
if ( str[i] >= 'a' && str[i] <= 'z' )
{
str[i] = str[i] - 32;
}
}
}
void main ( )
{
char str[40];
clrscr ( );
printf("\n\n\n\t\t Enter a string..: "); gets(str);
print_upper ( str );
printf("\n\n\t\t The upper case string is..: %s",str);
getch ( );
}
Click here to contact us
No comments:
Post a Comment