C program to find all even numbers from an Array.

Question: Write a C program to take 5 numbers from user and display all even numbers from them.

Source Code:

#include <stdio.h> int main() { int arr[5],i; printf("Enter 5 numbers\n"); for(i=0;i<5;i++) { scanf("%d",&arr[i]); } printf("Even Numbers are:\n"); for(i=0;i<5;i++) { if(arr[i]%2==0) { printf("%d \n",arr[i]); } } return 0; }

Output:

Enter 5 numbers 34 23 45 56 34 Even Numbers are: 34 56 34

Comments

Popular posts from this blog

Introduction to Python.

Decision Making Statement.