or

5 Computer -- Programming II

Write a C program to input a number and check whether it is odd or even.

Write a C program to input a number and check whether it is odd or even.

#include<stdio.h>

void check(int);

int main()

{

    int n;

    printf("enter the number ");

    scanf("%d",&n);

    check(n);

}

void check(int n)

{

    if(n%2==0)

    {

        printf("%d is even number",n);

    }

    else{

        printf("%d is not even number",n);

    }

}


Output:

enter the number 7

7 is not even number

More questions on Programming II

Differentiate between structure and union.

Structures in C is a user-defined data type available in C that allows to combining of data items of different kinds. Structures are used to represent a record. 

Defining a structure: To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than or equal to one member. The format of the struct statement is as follows:

struct [structure name] { member definition; member definition; ... member definition;...
Close Open App