P
Peter Mount
Hello
I'm having trouble with " scanf("%c", &answer);" on line 20 below. When I
run the program in cygwin on Windows 98SE it skips that line completely and
ends the program. Does scanf have problems with "%c" or is it the operating
system I'm using?
1 #include <stdio.h>
2
3 int main()
4 {
5 float width, length, area;
6 char answer;
7
8 do{
9 printf("\nEnter width of the rectangle ");
10 scanf("%f", &width);
11 printf("\nEnter length of the rectangle ");
12 scanf("%f", &length);
13
14 area = length * width;
15
16 printf("\nArea of the rectangle is %.2f", area);
17
18 printf("\nContinue? - Enter Y for yes, N for no ");
19
20 scanf("%c", &answer);
21
22 }while(answer == 'Y');
23
24 return 0;
25 }
26
Thanks
Peter Mount
(e-mail address removed)
I'm having trouble with " scanf("%c", &answer);" on line 20 below. When I
run the program in cygwin on Windows 98SE it skips that line completely and
ends the program. Does scanf have problems with "%c" or is it the operating
system I'm using?
1 #include <stdio.h>
2
3 int main()
4 {
5 float width, length, area;
6 char answer;
7
8 do{
9 printf("\nEnter width of the rectangle ");
10 scanf("%f", &width);
11 printf("\nEnter length of the rectangle ");
12 scanf("%f", &length);
13
14 area = length * width;
15
16 printf("\nArea of the rectangle is %.2f", area);
17
18 printf("\nContinue? - Enter Y for yes, N for no ");
19
20 scanf("%c", &answer);
21
22 }while(answer == 'Y');
23
24 return 0;
25 }
26
Thanks
Peter Mount
(e-mail address removed)