write a program to find the number of even integers and odd
integers in a given array in c language
Answers were Sorted based on User's Feedback
Answer / lakshmi
#include<studio.h>
#include<conio.h>
main()
{
int a[5],count_even=0,count_odd=0,i;
for(i=0;i<5;i++)
scanf("%d",&a[i]);
/* display the number of odd and even intergers */
for(i=0;i<5;i++)
{
if((a[i]%2 ==0))
count_even++;
if((a[i]%2==1))
count_odd++;
}
printf("%d %d",count_even,count_odd);
getch();
}
Is This Answer Correct ? | 217 Yes | 96 No |
Answer / rahul khare
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],even=0,odd=0,i;
for(i=0;i<9;i++)
{
if(a[i]%2==0)
{
printf("%d\t",a[i]);
even++;
}
else
{
printf("%d\t",a[i]);
odd++;
}
}
printf("Total no of Even found is=%d",even);
printf("Total no of Odd found is=%d",odd);
getch();
}
Is This Answer Correct ? | 134 Yes | 75 No |
#include<stdio.h>
#include<conio.h>
main()
{
int x;
clrscr();
printf("Enter the value");
scanf("%d",& x);
if(x%2==0)
printf("x is even");
else
printf("x is odd");
getch();
}
Is This Answer Correct ? | 54 Yes | 45 No |
Answer / anup majhi
#include<stdio.h>
#include<conio.h>
#define size 100
void check(int[],int);
int i;
main(){
int a[size],m
printf("Enter the array length ");
scanf("%d",&m);
printf("Supply elements to the array ");
for(i=0;i<m;i++)
scanf("%d",&a[i]);
check(a,m);
}
void check(int a[],int b){
int even=0,odd=0;
for(i=0;i<b;i++){
if(a[i]%2==0)
even++;
else
odd++;
}
printf("Number of even no. in the array =%d ",even);
printf("\nNumber of odd no. in the array =%d ",odd);
}
out put:
Enter the array length 5
Supply array elements 1 2 3 4 5
Number of even no. in the array =2
Number of odd no. in the array =3
Is This Answer Correct ? | 11 Yes | 4 No |
Answer / ravestar
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
main()
{clrscr();
int a[5],count_even=0,count_odd=0,i;
for(i=0;i<5;i++)
scanf("%d",&a[i]);
for(i=0;i<5;i++)
{
if((a[i]%2 ==0))
count_even++;
if((a[i]%2==1))
count_odd++;
}
cout<<"Even:"<<count_even<<"\n"<<"Odd:"<<count_odd;
getch();
}
Is This Answer Correct ? | 8 Yes | 7 No |
Answer / ankit kr. sharma
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,neg=0,even=0,odd=0;
printf("Enter the elements for the array:\n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("The array is:");
for(i=0;i<10;i++)
{
printf("%d\t", a[i]);
}
for(i=0;i<10;i++)
{
if (a[i]<0)
neg++;
else if(a[i]%2==0)
even++;
else
odd++;
}
printf("\nthe odd no.s in the array are: %d\t",odd);
printf("\nthe negative no.s in the array are: %d\t",neg);
printf("\nthe even no.s in the array are: %d\t",even);
}
Is This Answer Correct ? | 10 Yes | 11 No |
Answer / ankit kumar sharma
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],count_even=0,count_odd=0,i;
printf("Enter the value in Array\n");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
/* Calculating number of odd and even intergers */
for(i=0;i<5;i++)
{
if((a[i]%2 ==0))
count_even++;
if((a[i]%2==1))
count_odd++;
}
/* display the number of odd and even intergers */
printf(" Total number of even integer are %d\n ",count_even);
printf("Total number of odd integer are %d", count_odd);
getch();
}
Is This Answer Correct ? | 13 Yes | 16 No |
Answer / merlin
#include<studio.h>
#include<conio.h>
void main()
{
int a[20],even=0,odd=0,i,n;
printf("Enter the size of the array");
scanf("%d",&n);
printf("Enter the elements");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if((a[i]%2 ==0))
even++;
else
odd++;
}
printf("%d %d",even,odd);
getch();
}
Is This Answer Correct ? | 15 Yes | 19 No |
Answer / ks djd
#include<stdio.h>
void main()
{
int a[10],i,b;
for(i=0;i<10;i++)
{scanf("%d",&a[i]);
}
printf("enter element to be searched:");
scanf("%d",&b);
for(i=0;i<10;i++)
{
if(a[i]==b)
printf("element found at location %d\n",i);
}
}
Is This Answer Correct ? | 7 Yes | 17 No |
Answer / anshul
#include<stdio.h>
void main()
{
int a[10],i,b;
for(i=0;i<10;i++)
{scanf("%d",&a[i]);
}
printf("enter element to be searched:");
scanf("%d",&b);
for(i=0;i<10;i++)
{
if(a[i]==b)
printf("element found at location %d\n",i);
}
}
include
Is This Answer Correct ? | 6 Yes | 16 No |
i want to know aptitude questions,technical questions
Explain about the constants which help in debugging?
what are the advantages of a macro over a function?
How many levels of indirection in pointers can you have in a single declaration?
0 Answers Agilent, ZS Associates,
What are extern variables in c?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database
2 Answers TCS, Unisys, Webyog,
write a programe returns the number of times the character appears in the string
for questions 14,15,16,17 use the following alternatives:a.int b.char.c.string.d.float
What is atoi and atof in c?
Is a house a shell structure?
Differentiate between new and malloc(), delete and free() ?
what are the advantage of pointer variables? write a program to count the number of vowels and consonants in a given string