Hello. I am writing a program that prompts the user to enter 5 characters and then prints them in a wedge shaped like ">". This is my code:
Code:
#include <stdio.h>
int main()
{
char first, second, third, fourth, fifth;
printf("First character: ");
scanf("%c", &first);
printf("Second character: ");
scanf("%c", &second);
printf("Third character: ");
scanf("%c", &third);
printf("Fourth character: ");
scanf("%c", &fourth);
printf("Fifth character: ");
scanf("%c", &fifth);
printf("%c", first);
printf("%3c", second);
printf("%5c", third);
printf("%3c", fourth);
printf("%c\n", fifth);
return 0;
}
When I compile and run the program, however, after inputting the first character and pressing enter, "Second character: Third character: " prints all at once, and then "Fourth character: Fifth character: " prints all at once, as well. Can someone help me understand why it is not going along one command at a time?
Thanks,
Steve