I need a statement to exit my program after goto statement but i dont know where to place this statement. The statement is:
printf ("Enter \".\" to exit or \"p\" to proceed");
scanf("%c",&ch);
if (ch=='.')
getch();
if (ch=='p')
goto repeat;
also tell me if its rite or not?
#include<stdio.h>
#include<conio.h>
void main ()
{
int cy,cm,cd,by,bm,bd,age,month,days;
char ch;
clrscr();
repeat:
printf("\nEnter current year:");
scanf("%d",&cy);
printf("\nEnter current month:");
scanf("%d",&cm);
printf("\nEnter current date:");
scanf("%d",&cd);
printf("\nEnter birth year:");
scanf("%d",&by);
printf("\nEnter birth month:");
scanf("%d",&bm);
printf("\nEnter birth date:");
scanf("%d",&bd);
if (cy<=0 || cm<=0 || cd<=0 || by<=0 || bm<=0 || bd<=0)
{
printf("\nEnter correct date");
goto repeat;
}
else
if (cm>=13 || bm>=13 ||cd>=32 ||bd>=32)
{
printf("\nDont exceed the date limit");
goto repeat;
}
else
if (cm<bm && cd<bd)
{
days=30+cd-bd;
month=cm-1+12-bm;
age=cy-1-by;
printf("\nYour age is");
printf("\n%dyears-%dmonths-%ddays",age,month,days);
}
else
if (cm>bm && cd<bd)
{
days=30+cd-bd;
month=cm-1-bm;
age=cy-by;
printf("\nYour age is");
printf("\n%dyears-%dmonths-%ddays",age,month,days);
}
else
if (cm<bm && cd>bd)
{
days=cd-bd;
month=12+cm-bm;
age=cy-1-by;
printf("\nYour age is");
printf("\n%dyears-%dmonths-%ddays",age,month,days);
}
else
if(cm>=bm && cd>=bd)
{
days=cd-bd;
month=cm-bm;
age=cy-by;
printf("\nYour age is ");
printf("\n%dyears-%dmonths-%dage",age,month,days);
}
getch();
}