using repetition structure. Write a c program that will
accept five numbers. The program should count and output the
total count of even numbers and total count of add numbers.

Answers were Sorted based on User's Feedback



using repetition structure. Write a c program that will accept five numbers. The program should cou..

Answer / abikrishna

#include <iostream>
using namespace std;



int main ()
{
int a[6],i,ec=0,oc=0;
for(i=0;i<5;i++)
cin>>a[i];

for (i=0;i<5;i++)
{
if (a[i]%2==0)
ec++;
else
oc++;
}
cout<<"\t Even Count is : "<<ec;
cout<<"\t Odd Count is : "<<oc;

return 0;
}

Is This Answer Correct ?    22 Yes 9 No

using repetition structure. Write a c program that will accept five numbers. The program should cou..

Answer / john

#include <iostream>
using namespace std;

int main(){
int array[5];
int i;
int evens = 0;
int odds = 0;

for(i = 0; i < 5; i ++){
cout << "Enter number: ";
cin >> array[i];
if(array[i] & 1)
odds++;
else evens++;
}

cout << "\nEvens: " << evens;
cout << "\nOdds: " << odds;
}

Is This Answer Correct ?    7 Yes 9 No

Post New Answer

More C++ Code Interview Questions

. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].

2 Answers   IBM,


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

0 Answers  


A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E

1 Answers  


#include<stdio.h> #include<conio.h> void main() { char str[10]; int,a,x,sw=0; clrscr(); printf("Enter a string:"); gets(str); for(x=0;x<=a;a++); for(x=0;x<=a;x++) { if(str[x]==str[a-1-x]) { sw=1; } else sw=0; } if(sw==10 printf("The entered string is palindrome:"); else printf("The entered string is not a palindrome:); } getch(); } wht would be the explanation with this written code???

2 Answers  


write a program that reverses the input number of n.Formulate an equation to come up with the answer.

0 Answers   Satyam,






what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }

0 Answers  


Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++

0 Answers  


write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150

0 Answers  


write a program using 2 D that searches a number and display the number of items 12 inputs values input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20 enter no. to search : 20

0 Answers  


1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.

2 Answers  


3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

0 Answers  


Code for Two Classes for Doing Gzip in Memory?

0 Answers  


Categories