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

Recommended Answers

All 4 Replies

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.

commented: Nice answer! +15

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.