- #1
blue_tiger30
- 29
- 0
hello
I'm a beginner in c programming. I wrote a code that converts the lower case that the user entered to upper case characters.
I want to improve my program , but since I'm a beginner i might not be aware of some technics .
my program can only allow you to enter as many characters as you want but without using space (one word ) .
1. how can i allow the user to enter more than one word ?
2. when i say char letter[20]; what does the 20 mean , because i entered more than 20 characters and it worked fine .the code is
what I get is
I'm a beginner in c programming. I wrote a code that converts the lower case that the user entered to upper case characters.
I want to improve my program , but since I'm a beginner i might not be aware of some technics .
my program can only allow you to enter as many characters as you want but without using space (one word ) .
1. how can i allow the user to enter more than one word ?
2. when i say char letter[20]; what does the 20 mean , because i entered more than 20 characters and it worked fine .the code is
Code:
#include <stdio.h>
#include <string.h>
int main (void) {
char letter[20];
printf("please enter lower-case character without spaces and then press enter to get them in upper case:");
scanf("%s",letter);
int nameLength = strlen(letter);
int i;
printf("\nthe upper case characters of your entry is : \n");
for (i=0;i<nameLength;i++) {
int u=letter[i]-32;
printf("%c",u);
}
return 0;
}
Here I tried checking if the entry was a lower case , but that didnt work even if I enter an upper case it will print -32 form itplease enter lower-case character without spaces and then press enter to get them in upper case:hello there
the upper case characters of your entry is :
HELLO
Code:
#include <stdio.h>
#include <string.h>
int main (void) {
char letter[20];
printf("please enter lower-case character without spaces and then press enter to get them in upper case:");
scanf("%s",letter);
int nameLength = strlen(letter);
int i;
printf("\nthe upper case characters of your entry is :");
int u;
if ( u > 96 ) {
for (i=0;i<nameLength;i++) {
int u=letter[i]-32;
printf("%c",u);
}
}
else {
printf("invalid input");
}
return 0;
}
please enter lower-case character without spaces and then press enter to get them in upper caseDDD
the upper case characters of your entry is :$$$$$
Last edited: