This program helps to Find Even Numbers using C Program . This is the simple C language Program to find the even numbers in a given range. User can give any number in the variable but it executes and prints even numbers.
How the code works?
- #include<stdio.h> – The C programming language provides many standard library functions for file input and output. stdio means standard input output library.
- #include<conio.h> – The conio.h used to display the result.
- main() – The c programming starts with main function. The main functions opening brace indicates start of the program and closing brace indicates end of the program.
- int n; – This is the integer variable declared to initialize the value.
- n=10; – n value initialized to 10
- int i=2; – i value initialised to 2
- while(i<=n) – while loop created to check the record. if i is less than n then the condition executes else the loop condition becomes false.
- if((i%2)==0) – This condition check whether the reminder of division is available or not. If the reminder is available in this condition then the condition becomes false. The logic is reminder of division displays only for odd numbers. If it is even number then the condition becomes true.
- printf(“%d”,i); – printf statement to print the record. here it prints the value of i. Each time the condition loops the i value increases.
- i++ means it increases its value. i value increases until the condition becomes false. When the condition becomes false then the system displays the result of even numbers.
- getch(); – this is the function which diplays output.
Find Even Numbers using C Program
/*Coding to find and display the even number*/
n=10;/*For Given Number*/