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
What is the advantage of an array over individual variables?
Is swift based on c?
How can my program discover the complete pathname to the executable from which it was invoked?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
What is data type long in c?
What does s c mean on snapchat?
When was c language developed?
Explain what is a stream?
Is there a way to switch on strings?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
What are the disadvantages of c language?
Does free set pointer to null?
Where register variables are stored in c?
What is difference between array and pointer in c?
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.