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

which typw of errors ? & how to solve it ?

0 Answers  


I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


how tally is useful?

2 Answers  


I am using Qt 5.6 during compilation it stops and gives error about Qmake The process "C:QtQt5.6.35.6.3msvc2015_64inqmake.exe" crashed. Error while building/deploying project untitled1 (kit: Desktop Qt 5.6.3 MSVC2015 64bit) When executing step "qmake"

0 Answers  


quoroum of computer languages?

0 Answers   Infosys,


printy(a=3,a=2)

3 Answers  


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

2 Answers  


void main() { int i=5; printf("%d",i+++++i); }

14 Answers   HCL,


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  


I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX

0 Answers  


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

4 Answers  


Categories