Assumptions:
1. The user inputs from command line
2. The output shown in command line
#include <stdio.h>
#include <string.h>
int main() {
char txt[100];
int i;
//Enter the Text
printf("\nEnter a string : ");
//Reading String
fgets(txt, sizeof(txt), stdin);
//Looping String
while (txt[i]) {
//converting alphabets to Uppercase
if(txt[i] >= 'a' && txt[i] <= 'z') {
txt[i] = txt[i] - 32;
}
i++;
}
//Prints the output
printf("\nString in Upper Case: ");
puts(txt);
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.