MS Rumi. Powered by Blogger.
Showing posts with label iostream. Show all posts
Showing posts with label iostream. 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



Power Of X In C++

File Handling Example In C++

Write a C++ Program that computes the equation (y) to the power of (x) and print the result on file.

//Before creating this program. Create a txt file on note pad with "powerX.txt" name.

#include<iostream.h>
#include<fstream.h>
void main ()
{
int number,power,result=1;

ofstream powers;
powers.open("powerX.txt");
cout<<"Enter Numbers:";
cin>>number;
cout<<"Enter Power:";
cin>>power;
for(int i=1; i<=power; i++)
{
result=number*result;
}



powers<<"Number:"<<number<<"\nPower:"<<power<<endl;
powers<<"Result:"<<result;


}

OUT PUT On FILE

Thursday, 24 April 2014

Program To Print Small Letters

C++ Program To Print a To z

Write a program to print the small letters from (a → z) in c++.

// You can use same program for the Capital latter replace small 'a' with capital 'A'.
#include<iostream.h>
void main ()
{
char ch='a';
for(int i=1;i<=26;i++)
{
cout<<ch<<",";
ch++;
}

}

E-mail Newsletter

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

Recent Articles

TOP