#include<stdio.h>
#include<conio.h>
void main()
{
int num;
char ch;
clrscr();
do{
printf("Enter a number");
scanf("%d",&num);
printf("\n\n");
printf("You entered %d",num);
printf("Press 'y' to restart again?");
ch=getche();
}
while(ch=='y');
getch();
}
If you have question, you can ask me freely!
#include<conio.h>
void main()
{
int num;
char ch;
clrscr();
do{
printf("Enter a number");
scanf("%d",&num);
printf("\n\n");
printf("You entered %d",num);
printf("Press 'y' to restart again?");
ch=getche();
}
while(ch=='y');
getch();
}
If you have question, you can ask me freely!
2 comments:
I'm sorry, i'm new at programming. Can you tell me how to restart this program?
#include
#include
#include
int main()
{
char answer;
char ch;
do{
printf("Do you like cakes? (s/n)\n");
scanf("%c",&answer);
if (answer=='s') {
printf("Nice! \n");
} else if (answer=='n') {
printf("Ehm... okk..\n");
} else {
printf("Press 'y' to restart\n");
ch=getch();
}
}
while (ch=='y');
getch();
system("pause");
return 0;
}
Hi,
Change ch=getch(); to ch=getche();
Post a Comment