write a c program to input the number and print the even number

See if you can adapt the given program if I tell you that you can use the following line to check if a number is even:

if (n % 2 == 0)

where n is the variable that contains the number. The operator % performs the modulo operation, see http://en.wikipedia.org/wiki/Modulo_operation .main()

{

int n;

printf("Enter the number :");

scanf("%d",&n);

if(n%2==0)

printf("\nThe number is even");

else

printf("\nThe number is odd");

}

Related Discussions

- 2
### How to write a simple C Program for calculating a sum of integers?

by Naveed Ahmed2 years ago

How to write a simple C Program for calculating a sum of integers?In C Programming using C++ Environment, I want to calculate the sum of some continuous integers, say 1 to 10. I have studies some loop structures like...

- 4
### Write a C program to compute the average marks in a subject of all the students

by aparnatrivedi7 years ago

Write a C program to compute the average marks in a subject of all the students in a class.

Copyright © 2018 HubPages Inc. and respective owners.

Other product and company names shown may be trademarks of their respective owners.

HubPages^{®} is a registered Service Mark of HubPages, Inc.

HubPages and Hubbers (authors) may earn revenue on this page based on affiliate relationships and advertisements with partners including Amazon, Google, and others.

terms of use privacy policy (0.69 sec)

working