Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

Answers were Sorted based on User's Feedback



Write a C program to enter 10 integer numbers through one variable and count how many of them are ev..

Answer / nipun

#include<stdio.h>
#include<conio.h>

void main()
{
int var;
int count=0;
int n=0;
clrscr();
while(n<10)
{
printf("Enter the number:");
scanf("%d",&var);
if(var%2 == 0)
{
count++;
n++;
}
else
{
n++;
continue;
}
}
printf("Even numbers present:%d",count);
getch();
}

Is This Answer Correct ?    5 Yes 1 No

Write a C program to enter 10 integer numbers through one variable and count how many of them are ev..

Answer / sansiri

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=0;
int count=0;
printf("\n Enter the 10 integer numbers");
while(i<10)
{
scanf("%d",&n);
if(n%2==0)
{
count++;
}
i++;
}
printf("\nCount of even numbers:%d",count);
getch();
}

printf

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C C++ Errors Interview Questions

How to convert hexadecimal to binary using c language..

1 Answers   Bajaj, GAIL, Satyam, Zenqa,


What are the different types of errors in C and when they occur?

4 Answers  


Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .

2 Answers  


write a profram for selection sort whats the error in it?

2 Answers  


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  






#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }

19 Answers  


Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


who was the present cheif governor of reserve bank of india

6 Answers   State Bank Of India SBI,


what is run time error?

7 Answers  


To generate the series 1+3+5+7+... using C program

18 Answers  


Declaration of Cube Guys please help me.. Is this a right way to declare cube.? If i Compile it. It Says: Cube undeclared what should i do? Please help \thanks in advanced #include<stdio.h> #include<math.h> #include<conio.h> main( ) { float x,y; while(x++<10.0) { printf("Enter Number:"); scanf("%d", &x); y = cube(x); printf("%f %f %f \n", x,pow(x,2),y); cube(x); } { float x; float y; y = x*x*x; } getch(); return (y); }

2 Answers  


errors are known as?

3 Answers   EX, State Bank Of India SBI,


Categories