An interesting C++ program using loops

June 16, 2009 · Print This Article · Email It

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<iostream.h>
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<a[i];j++)
		{
			cout<<a[i];
		}
		cout<<endl;
	}
}

Comments

View Comments to “An interesting C++ program using loops”
  1. prateek says:

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

  2. prateek says:

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

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

blog comments powered by Disqus