#include<stdio.h>
void main(){
char loop;
do{
char c;
printf("Enter a character: ");
scanf("%c",&c);
printf("ASCII value of %c is %d",c,c);
printf("\nAnother test: (y/n)? ");
scanf("%c",&loop);
}while(loop=='y');
}
Please anyone explain why this code is not working properly. Actually loop exits after just one iteration.
But Code written below is working fine:-->
#include<stdio.h>
void main(){
int a,b,sum;
int loop=0;
do{
printf("Enter two numbers: ");
scanf("%d%d",&a,&b);
sum=a+b;
printf("Sum of this two numbers %d",sum);
printf("\nOne more time: (0/1)?");
scanf("%d",&loop);
}while(loop==1);
}