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 |
write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
1 Answers 91mobiles, Amazon, App Guruz, College School Exams Tests, Folio3, Infosys, Omega, Planin, Riphah International University, Subex,
how to find sum of digits in C?
can anyone please tell about the nested interrupts?
Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;
what is the difference b/w NULL and null?
What is a string?
Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i; Output of i after executing the program
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What is the c language function prototype?
What is fflush() function?
print ur name 20,000 times without using inbuilt library functions like printf,scanf,gets,puts,getchar or putchar