0

I need a program which shows the number is even or odd and print the table of 2 if the any even number we enter and when we enter the any odd number the program print the table of three please help as soon as possible

3
Contributors
4
Replies
15
Views
3 Years
Discussion Span
Last Post by Learner010
1

All we can do is to answer (if we know) specific questions, asked upon specific code/logic related errors. I see only a statement and a request, not a question.
Please formulate a question regarding a specific part of your assignment that is giving you a hard time, and also post some code too.

P.S. We do not solve homeworks/assignments, it's your job.

Good luck.

Edited by Lucaci Andrew

Votes + Comments
Nice answer!
0

we don't do your homeworks , its your duty to complete it.
but as a help i can suggest the following structure , you can use to solve your assignments.

if(n is even)
{
//write code to print the table for 2
}
else
{
//write code to print the table for 3
}

to check if n is even or odd , you can use % with 2(n%2) and check if the result of the expression is equal to 0 then its even otherwise odd.
And nothing extra i can do for you , if you fail to prove what you done so far to solve your assignment.

0

include <iostream.h> main() { int num,x; cout<<"Please enter a number"; cin>>num; if(num%2==0) { cout<<"Numbers are even"; } else { cout<<"numbers are odd"; } cout<<"Please enter a number you want the table of...!!!"; cin>>num; x = 1; while(x<=10) { cout<<"\n"<<<<" numx "<<x<<" = "<<x*num; x++ ; } system("pause"); }

here is the code but the program print every number table which is odd or even

Edited by sohail.butt.144

0

it should be

#include<iostream>
using namespeace std;
int main()
{
int num,x=1;
cout<<"enter number";
cin>>num;
if(num%2==0)
{
    cout<<"Even";
    for(;x<=10;x++)
    {
    cout<<(2*x)<<endl;
    }
}
else
{
    cout<<"Odd";
    for(;x<=10;x++)
    {
    cout<<(3*x)<<endl;
    }
}
return 0;
}

and don't forget to use code button when you are posting code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.