
Example program:
#include<iostream.h>
#include<conio.h>
void main()
{
char ans=’y';
int x=1,y;
while(ans!=’n'||ans!=’N')
{
count<<”Enter repetions :”;
cin>>y;
while(x<=y)
{
cout<<x<<endl;
x++;
}
x=1;
cout<<endl<<”Continue (y/n) ?;
cin>>ans;
}
}
Output:
Enter repetitions :2
1
2
Continue (y/n) ? y
Enter repetitions :4
1
2
3
4
Continue (y/n) ? y
Enter repetitions :1
1
Continue (y/n) ? n
See also: For loop in C++
Not Satisfied ? Just search & get the result
Related posts:
