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
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 |
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 |
void main() { int i,j=2; for(i=0;i<3;i++) if(j=i) cout<<"Lotus "; else cout<<"Rose "; } Its result is Rose Lotus Lotus.. How? Explain it?
write a function -oriented program that generates the Fibonacci, the current numbers of n(as input) and display them (series). In Fibonacci, the current third number is the sum of the previous number.
write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?
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.
How to Split Strings with Regex in Managed C++ Applications?
what is the use of using for loop as "for(;;)"?
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
using friend function find the maximum number from given two numbers from two different classes.write all necessary functions and constructor for the classes.
Write code for the multiplication of COMPLEX numbers?
Code for Two Classes for Doing Gzip in Memory?
what is virtual constroctor ? give an exam for it?-(parimal dhimmar)
program to find the magic square using array