Code:
#include<stdio.h>
#include<string.h>
int main() { //function declarations go all the way to the left hand side
char str1[100]; //all other functions lines get indented 1 level
char name [100]; //each level of indentation is 2-4 char's
printf("Enter your first name:\n"); //use spaces, not tabs
fgets(str1, sizeof(str1), stdin); //in the code
sscanf(str1, "%s", name);
int i = 0; //blank lines offset blocks of code
//like this one - nice! :)
while (i <= strlen(name)) { //one space before the brace to highlight it
if((name[i] >= 'A') && (name[i] <= 'Z'))
name[i] = name[i] + 32;
i++; //NOT THIS LOOKS part of the if() statement, but it's not
i++; //like THIS!
}
char eman[100];
int y;
i=0;
while (i <= strlen(name)) {
y = strlen(name) - i;
name[y] = eman[i];
i++;
}
printf("%s", eman);
return(0);
}
If I gave you five letter blocks a-e, arranged in abcde order, how would you reverse them, just on the kitchen table?
Describe that, in detail. Step by step. How are you doing it? (and don't say "by using my fingers", either, you smart-ass!)
Now write that up in pseudo code - that's the skeleton of your program's logic.