Wednesday, August 24, 2011

PROGRAM TO GENERATE TABLE STARTING AND ENDING VALUE AS INPUT C/C++

This program will ask user to enter 3 values

Number for which table to be generated
On which number should the table start
On which number should the table end

CODING
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main()
{
int numb,start,end,ans;
cout<<"Enter your number ";
cin>>numb;
cout<<"\nEnter your starting value ";
cin>>start;
cout<<"\n Enter your ending value ";
cin>>end;
if(start>end)
{
    for(int a=start; a>=end; a--)
    {
        ans=numb*a;
        cout<<ans<<endl;
    }
}

for(int a=start; a<=end; a++)
cout<<numb*a<<endl;
getche();
}

No comments:

Post a Comment