write a program to find the number of even integers and odd
integers in a given array in c language
Answer Posted / 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 |
Post New Answer View All Answers
Explain about the constants which help in debugging?
What is a global variable in c?
What is %lu in c?
What is null pointer in c?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
How can this be legal c?
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
What is wild pointer in c with example?
How to write a code for implementing my own printf() and
scanf().... Please hep me in this... I need a guidance...
Can you give an coding for c... Please also explain about
the header files used other than #include
What is variables in c?
What is ambagious result in C? explain with an example.
What are the types of pointers?
Explain how do you sort filenames in a directory?