Unable to get expected result please help

#include<stdio.h>
int main()
{
int num;
char another;
do
{
printf(“enter the number”);
scanf("%d", &num);
printf(“the square is %d” ,num*num);
printf(“want another y/n”);
scanf("%c",another);

}while(another=='y');
return 0;

}

there is error in your code →
scanf("%c",another);
your missing " & " and also " \n "
scanf("\n%c",&another);

The reason should be one of these

  • You are not reading the new line ('\n') character.
  • You are not reading the new line ('\n') character.
  • (Yells 1000 times)
  • You are not reading the new line ('\n') character.

ok i tried \n still not working

Paste the modified version of your code.

1 Like