Computer Science, asked by kaushikvidit007, 1 year ago

Write a C++ program to check whether the number is odd or even.


kaushikvidit007: Write in C language not C++

Answers

Answered by wwwalison8888a
12
Check this...
You may change the format accordingly...
Attachments:

wwwalison8888a: class Even_Odd
wwwalison8888a: {private int n;
wwwalison8888a: public void accept(int n)
wwwalison8888a: {if(n%==0)
wwwalison8888a: System.out.println("The number is even");
wwwalison8888a: else
wwwalison8888a: System.out.println("The number is odd");
wwwalison8888a: }}
wwwalison8888a: Got it..
wwwalison8888a: You are supposed to tell the type of format with your question that you want in your answer.
Answered by siddhartharao77
6
#include<iostream.h>
using namespace std;


int main()
{
int num;
cout<<"Enter the number:" ;
cin >> num;

if(num%2 == 0)
{
printf("Number is Even");
}
else
{
printf("Number is odd");
}

return 0;
}


<Hope this helps --!>


kaushikvidit007: btw correct is
kaushikvidit007: #include<conio.h>
#include<stdio.h>

int main()
{
int num;
printf("Enter the number:");
scanf("%f",& num);
if(num%2 == 0)
{
printf("Number is Even");
}
else
{
printf("Number is odd");
}

return 0;
getch();
}
kaushikvidit007: this is what i wanted, edit your answer
siddhartharao77: Haha.You have asked to qrite the question in c++.
siddhartharao77: The program which you have written is C. You have asked to write in C++.Thats what I have written
kaushikvidit007: what s this then?
siddhartharao77: You have asked to write a program in c++. I have written the program in c++ only. And you have written the same program in C.
kaushikvidit007: oops
kaushikvidit007: ill comment c
siddhartharao77: So, Now in which language you want me to write this program?
Similar questions