An interesting C++ program using loops

In this program, we will code a C++ program which will display a number the number of times the number. Like I type in a number 5 and I will see the number printed 5 times on the VDU and similarly 3 times if my number is 3.

#include
void main()
{
	int a[5];
	for(int i=0;i<5;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<5;i++)
	{
		for(int j=0;j

  • prateek

    what is interesting in it…..?????

    • Sandeep Goyal

      I m agree with u prateek

      • Might not be interesting for you guys. But when I was learning it in class XIth, felt like this was the coolest thing to do with loops :P

  • prateek

    what is interesting in it…..?????

  • C++ Expert

    it can be done in a more simpler way….

    #include
    #include
    void main()
    {
    int a;
    clrscr();
    cout< “;
    cin>>a;
    while(a)
    {
    cout<<a<<endl;
    a–;
    }
    getch();
    }

  • Suresh

    hi, i am suresh…
    i will tell a interesting program………….
    this program approximately identifies your sex with your name………
    here it is

    #include
    #include
    #include
    void main()
    {
    char a[50];
    int k,s;
    clrscr();
    cout<>a;
    k=strlen(a);
    s=k-1;
    if((a[s]==’a’||a[s]==’i’))
    cout<<"nnit's a girl name";
    else
    cout<<"nnit's a boy name";
    getch();
    }
     

    how is it…..