To display the output more than one time using for loop in C++ programming
Program to display output five times:
#include < iostream >
using namespace std;
int main ()
{
for(int a = 0; a < 5; a++)
{
cout << "Program";
}
return 0;
}
To display in a sequence:
#include < iostream >
using namespace std;
int main ()
{
for(int a = 0; a < 5; a++)
{
cout << "Program" << endl;
}
return 0;
}
with the use of endl the output will show in a line.
To display in a single line with space:
#include < iostream >
using namespace std;
int main ()
{
for(int a = 0; a < 5; a++)
{
cout << "Program" << " ";
}
return 0;
}
Add space in the inverted commas in the display syntax.
Comments
Post a Comment