It worked without the Y/N
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
clrscr();
int z[20],zenox;
char x;
for(zenox=0;zenox<20;zenox++)
{
printf("Enter the grade for student %d:\n",zenox+1);
scanf("%d",&z[zenox]);
if((z[zenox]>100)||(z[zenox]<0))
{
printf("Invalid grade\n");
zenox--;
}
if(z[zenox]>=90)
printf("Excellent\n\n");
else if(z[zenox]>=80)
printf("Above Average\n\n");
else if(z[zenox]>=70)
printf("Average\n\n");
else if(z[zenox]>=60)
printf("Satisfactory\n\n");
else
printf("Failure\n\n");
}
exit (0);
getch ();
return 0;
}
Then by wrapping it, it worked!
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
clrscr();
char x ='Y';
while (x=='Y') {
{
int z[20],zenox;
for(zenox=0;zenox<20;zenox++)
{
printf("Enter the grade for student %d:\n",zenox+1);
scanf("%d",&z[zenox]);
if((z[zenox]>100)||(z[zenox]<0))
{
printf("Invalid grade\n");
zenox--;
}
if(z[zenox]>=90)
printf("Excellent\n\n");
else if(z[zenox]>=80)
printf("Above Average\n\n");
else if(z[zenox]>=70)
printf("Average\n\n");
else if(z[zenox]>=60)
printf("Satisfactory\n\n");
else
printf("Failure\n\n");
}
}
printf("Do you want to continue? [Y/N]");
scanf(" %c",&x);
}
exit(0);
getch ();
return 0;
}
But is there anyway that it could use either Y or y? I tried it this way
Code:
char x ='Y'||'y';
while ((x=='Y')||(x=='y')) {
But it didn't seem to work.