Wednesday 9 July 2014

How to Write a Table in C++

Structure of the Problem Requirements 

In this Problem we writing the Code for table writing 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 

Enter the Numbers and Programme will display the table
Shows the output of Programme





Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment