Hello can you help me,i have problem of this if i will use scanf("%c",&repz);
my porgram will exit it will not loop to menu..but if i will change to %s this will loop to menu...but i declare variable repz as char...can you help me or explain on this why it will loop if i will use %s and not %c...thank you in advance hoping for your positive responds...

#include<stdio.h>



 int main()
  {

     int num1=0;
     int num2=0;
     int answer=0;
     int select=0;
     char repz;



    do{
       clrscr();

	do
	  {


	       printf("======MENU========");
	       printf("\n1. ADDITION");
	       printf("\n2. SUBTRACTION");
	       printf("\n===================");
	       printf("\nSelect your choice: ");
	       scanf("%d",&select);


	  }while(select > 2 || select <= 0 );

	       printf("\nInput num1: " );
	       scanf("%d",&num1);
	       printf("Input num2: ");
	       scanf("%d",&num2);

	       if(select==1)
		{
		  printf("\nAddition");
		  answer= num1+num2;
		 }
	       else
	      {
		 printf("subtraction");
		  if(num1>num2)
		   {
		     answer=num1-num2;
		    }
		   else
		    {
		      answer= num2-num1;
		    }
		}
		printf("\nThe answer: %d" ,answer);

		printf("\nDo you want to continue Y/N?: ");
		scanf("%s",&repz);
		repz=toupper(repz);
		if(repz=='N')
		 exit(0);

	 }
	 while(repz=='Y');


   getch();

  }
[LIST=1]
[/LIST]

Use getche() in place of scanf. why scanf is not working, answer of this question
is here

http://www.gidnetwork.com/b-59.html

repz=getch(); 
or 
repz=getche();//echo the character on screen

Best Of Luck

Yeah, Best of Luck. Since getche() is a non-standard function, it's use is suspect and not recommended. It has been defined in only a couple of the hundreds of compilers created.

And I already told him where the answer is :icon_wink:

Yeah, Best of Luck. Since getche() is a non-standard function, it's use is suspect and not recommended. It has been defined in only a couple of the hundreds of compilers created.

And I already told him where the answer is :icon_wink:

Hello sir thank you for the reply i will try this sir i will write again if i have doubt...more power to you sir..

Use getche() in place of scanf. why scanf is not working, answer of this question
is here

http://www.gidnetwork.com/b-59.html

repz=getch(); 
or 
repz=getche();//echo the character on screen

Best Of Luck

hello sir i tried it and it works...thank you so much sir for helping me...

This question has already been answered. Start a new discussion instead.