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 |
What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }
3 Answers CTS, IBM, Infosys, Qatar University,
write a program in c++ to scramble a bmp image file using a scramble key 0x7c and an XOR logic. print out the original image, the scrambled image and the program. Note: the first 24bytes of a bmp file contain the header information of the file.
swap prog
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
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.
what is the best algorithm to sort out unique words from a list of more than 10 million words(1 crore+)? we need the best technique in the terms of execution time.
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
0 Answers ASD Lab, Qatar University, UNV,
Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...
Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!
1 Answers Motorola, Qatar University,
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 program to perform generic sort in arrays?