3
I’m making a draft just to train the if
and the else
which will be subject in my next class in college. I want to get there and at least already have a basis of what the teacher will teach.
My question is this:.
When I ask the user to type s
(Yes) or n
(No) to show the tab works, but if the user type the S
uppercase letter IDE executes block else
.
How do I make the user only type uppercase letters on printf
?
Follow the code below.
#include <stdio.h>
#include <stdlib.h>
main(){
int num;
char sn;
printf("DESEJA ABRIR A TABUADA? S/N: ");
scanf("%c", &sn);
if(sn=='s') {
printf("\nDIGITE O NUMERO DA TABUADA QUE DESEJA: ");
scanf("%d", &num);
printf("\n%d x 1 = %d\n", num , num*1);
printf("%d x 2 = %d\n", num , num*2);
printf("%d x 3 = %d\n", num , num*3);
printf("%d x 4 = %d\n", num , num*4);
printf("%d x 5 = %d\n", num , num*5);
printf("%d x 6 = %d\n", num , num*6);
printf("%d x 7 = %d\n", num , num*7);
printf("%d x 8 = %d\n", num , num*8);
printf("%d x 9 = %d\n", num , num*9);
printf("%d x 10 = %d\n\n", num , num*10);
}
else
printf("\nOK, PROGRAMA FINALIZADO.\n\n");
system("pause");
}
Thank you very much friend, I got it here.
– Paulo Sergio G.M. Filho