0
#include <stdio.h>
int main(){
    char another;
    int num;
    do {
        printf("enter a number\n");
        scanf("%d", &num);
        printf("the square of %d is %d\n", num, num * num);
        printf("want to enter another numb ? y / n\n");
        scanf("%c", &another);
    } while(another == 'y');
}

In this code, I ask "want to enter another numb", I am not getting the second prompt for the user to answer, and the 'y' or 'n' doesn't get stored in the "another char", and the while loop isn't getting executed just once from the "do" in the beginning.

user438383
  • 4,338
  • 6
  • 23
  • 35
bob papa
  • 3
  • 2

0 Answers0