Code:
#include<stdio.h>
int main()
{
int i=0;
int ch='Y';
for(i=0;i<10 && ch=='Y';i++)
{
printf("Enter (Y/N) ->> ");
ch = getchar();
clear_buffer();
}
printf("You are out ofloop\n");
getchar();
return 0;
}
/*
my output
Enter (Y/N) ->> Y
Enter (Y/N) ->> Y
Enter (Y/N) ->> Y
Enter (Y/N) ->> Y
Enter (Y/N) ->> Y
Enter (Y/N) ->> Y
Enter (Y/N) ->> N
You are out ofloop
*/
NOTE: it accepts uppercase letters only. in order to change it suppost both upper and lower u got change something in loop.(add some more condition) i leave it to
ssharish2005