write a program to find the number of even integers and odd
integers in a given array in c language
Answer Posted / 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 |
Post New Answer View All Answers
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.
What is function in c with example?
What is pointer & why it is used?
What is n in c?
What extern c means?
What are static variables in c?
What are c identifiers?
How the c program is executed?
Describe the header file and its usage in c programming?
what is a constant pointer in C
What is the difference between memcpy and memmove?
When the macros gets expanded?
Explain the difference between ++u and u++?
What are identifiers c?
What is the difference between ‘g’ and “g” in C?