ncjimn
In Runtime
- Messages
- 471
Ok, not that I want you to help me do my HW, but here is my first assignment of C programming.
Feel free to explain as much as you can (it's only like 3 lines of code).
Don't think that I am a slacker or a stupid person, I just think that if someone who knows this stuff explains what's going on I can understand better.
So yeah, some help here.
1. Enter and compile the following C program.
main() {
int i;
char str[255]; // max name length is 255 chars long
printf("Input your first name: ");
scanf("%s", str);
for (i = 0; str != '\0'; i++) {
str = str | 0x20;
printf("%c", str);
}
printf("\n");
}
2. Modify the program in problem 1 to print the user's first name backwards (e.g., "thomas" outputs "samoht").
3. Modify the program in problem 1 to print out the user's name in all upper case (e.g., "thomas" outputs "THOMAS")
Thanks
Feel free to explain as much as you can (it's only like 3 lines of code).
Don't think that I am a slacker or a stupid person, I just think that if someone who knows this stuff explains what's going on I can understand better.
So yeah, some help here.
1. Enter and compile the following C program.
main() {
int i;
char str[255]; // max name length is 255 chars long
printf("Input your first name: ");
scanf("%s", str);
for (i = 0; str != '\0'; i++) {
str = str | 0x20;
printf("%c", str);
}
printf("\n");
}
2. Modify the program in problem 1 to print the user's first name backwards (e.g., "thomas" outputs "samoht").
3. Modify the program in problem 1 to print out the user's name in all upper case (e.g., "thomas" outputs "THOMAS")
Thanks