MS Rumi. Powered by Blogger.
Showing posts with label Nested For Loop. Show all posts
Showing posts with label Nested For Loop. Show all posts

Friday, 25 April 2014

Print Table From 2-20 in C++

Nested For Loop In C++

Write a program to print the product table of all numbers by for loop

#include<iostream.h>
void main ()
{
int num=1;
for(int i=2; i<=20;i++)
{
cout<<"Table Of "<<i<<endl;

for(int j=1; j<=10; j++)
{
cout<<i<<"X"<<j<<"="<<i*j<<endl;

}
cout<<endl;
}

}

OutPut


Loop in C++ 1 to 40 numbers

Nested For Loop In C++ 

Use for loop to print number (1 to 40)  5 on a line.

#include<iostream.h>
void main ()
{
int num=1;
for(int i=1; i<=8; i++)
{
for(int j=1; j<=5; j++)
{
cout<<num;
num++;
}
cout<<endl;
}

}


OutPut



E-mail Newsletter

Sign up now to receive breaking news and to hear what's new with us.

Recent Articles

TOP