Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed write a program to check whether the given numbers is odd or even

+17 votes
asked Jun 2, 2024 by jai bhawani (220 points)
closed Jun 5, 2024 by Admin
closed with the note: answered

6 Answers

+3 votes
answered Jun 2, 2024 by Prisha Rai (200 points)
#include<iostream>

using namespace std;

int main(){

int n;

cout<<"enter n:";

cin>>n;

if(n%2==0){

cout<<"even number";

}

else{

cout<<"odd number";

}

return 0;

}
+3 votes
answered Jun 2, 2024 by Swapnil Yeolekar (200 points)
#include<iostream.h>
int main()
{
    int n;
    cout<<"enter any no.";
    cin>>n;
    if (n%2==0)
    {
        cout<<"no. is even";
    }
    else
    {
        cout<<"no. is odd";
    }
}

this is  for turbo c++
commented Jun 3, 2024 by Peter Minarik (101,360 points)
Your code is missing the following:

- "using namespace std;" or fully qualified name for the imported functions: e.g.: "std::cout".
- return statement from the end of the main function
0 votes
answered Jun 3, 2024 by Manikandan G (140 points)
#include <stdio.h>
#include <stdint.h>

#define IS_ODD(x) (x&1)?1:0

int main(int argc, char** argv) {
    
    printf("is number odd %d", IS_ODD(6));
    
    return 0;
 
}
+1 vote
answered Jun 4, 2024 by AMAN GUPTA (160 points)

#include<stdio.h>

int main()

{

int a;

printf(" ENTER A NUMBER", a);

scanf("%d", &a);

printf("%d", a%2==0);

}

0 votes
answered Jun 4, 2024 by Simran Sharma (140 points)
#include <stdio.h>
int main()
{
    int a = 20;
    if(a%2==0)
        printf("%d is an even number", a);
    else
        printf("%d is an odd number", a);
    return 0;
}
0 votes
answered Jun 4, 2024 by Sagarika Lucky (140 points)
import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter any positive number to check whether it is even or odd: ");

while(true){

    int num = sc.nextInt();

    if(num > 0){

        check(num);

        break;

    }else{

        System.out.println("Please enter positive number!!!");

    }

}

}

public static void check(int n){

    if(n%2 == 0){

        System.out.println("Even Number");

    }else{

        System.out.println("Odd Number");

    }

}

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...