In this Problem we are writing the Code for table in C++. The Important thing in this Code is just to make the Format of the Table with Multiplication. User can input any Number and this peace of Code will Display the Complete Table of entered numbers.
Source Code
#include <iostream>
#include <iomanip>
using namespace std;
/*
create a table in c++ while using the FOR Loop. it is easy and understandable for beginner level student
*/
int main()
{
int userInput ; //declare a variable
int size = 11 ; //intilize a varibale , this is for size mean table starting from 1 and goes to 10
cout<<endl<<endl<<"****************************** MATH TABLE ************************"<<endl;
cout<<endl<<"Enter a Digit for Table :";
cin>>userInput; //Recieveing a digit for table
cout<<endl;
/*
This is for loop which is dtarting from one and goes to 10 or variable size whihch is equal to 10
you can intiate the value of i from where you want to start Table
*/
for(int i=1 ; i<size ; i++)
{
int result = userInput * i ;
cout<<setw(30) << userInput <<" * "<< i << " = " << result<<endl<<endl;
}
return 0;
}
Output of the Program
Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of
BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
0 comments:
Post a Comment