Tuesday, 3 March 2015

C++ Program To Print Table Of Any Given Number

Problem :- Write A Program To Find Table Of Any Given Number Entered By User

Logic :- Take a input from user then use an any loop and start with condition =1;condition <=10; and increase by one each time ,and multiply input with condition and print .

Solution :-

Method 1:- 

#include<iostream>
using namespace std;

int main()
{
    int i,a,num;
    cout<<"Enter The Number That You Want To Print Table \n";
    cin>>num;

    for(i=1;i<=10;i++)
    {
        a=num*i;
        cout<<num<<" * "<<i<<" = "<<a<<endl;
    }

    return 0;

}

Method 2:- Here is An Another Way to Find Any  Table

 #include<iostream>
using namespace std;
int main()
{
    int i,j,num;
    
    cout<<"Enter The Number That You Want To Print Table \n";
    cin>>num;
    
    for(i=num,j=1;j<=10 &&i<=10*num;i=i+num,j++)
    {
        cout<<num<<" * "<<j<<" = "<<i<<endl;
    }
    return 0;
}

Output:-

C++ Program To Print Table Of Any Given Number

Ghanendra Yadav
Ghanendra Yadav

I Am Ghanendra Yadav Owner Of This Website. I Love Programming, Web Developing, Logo Making, Banner And Website designing. Currently I Am Studying In NIT Warangal And Also Working With WSDC( As Web Application Developer ) In NIT Warangal For Any Query Mail Me I Will Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment