In: Computer Science
#include <iostream>
using namespace std;
int main() {
int even=0,odd=0,sum=0,sum2=0,largest,smallest;
int num,i;
for ( i=1; i<=10; i++){
cout << " Enter " << i << " number: ";
cin >> num;
if ( num%2==0){
even++;
sum+=num;
}
else {
odd++;
sum2+=num;
if(num>largest){
largest = num;
}
if(num<largest) {
smallest = num;
}
}
cout << " The sum of even number is : " << sum << endl;
cout << " The total-count of even number is : " << even << endl;
cout << " The sum of odd number is : " << sum2 << endl;
cout << " The total-count of odd number is : " << odd << endl;
cout << " The largest number is : " << largest << endl;
cout << " The smallest number is : " << smallest << endl;
}
=====
CAN SOMEONE FIX MY CODE ?? BECAUSE THE SMALL INTEGER WONT SHOW THE CORRECT VALUE , PLEASE DONT USE ANY PREPROCESSOR DIRECTIVES ONLY <IOSTREAM> AND JUST FIX SOMEHTING TO MY CODE SO THE SMALLER INTEGER WILL SHOW THE CORRECT VALUE
=====
#include <iostream>
using namespace std;
int main() {
int c=0;
int even=0,odd=0,sum=0,sum2=0,largest,smallest;
int num,i;
for ( i=1; i<=10; i++){
cout << " Enter " << i << " number: ";
cin >> num;
if(c==0){
largest=num;
smallest=num;
c=c+1;
}
if(num%2==0){
even++;
sum+=num;
}
else
odd++;
sum2+=num;
if(num>largest){
largest = num;
}
if(num<largest) {
smallest = num;
}
}
cout << " The sum of even number is : " << sum <<
endl;
cout << " The total-count of even number is : " << even
<< endl;
cout << " The sum of odd number is : " << sum2 <<
endl;
cout << " The total-count of odd number is : " << odd
<< endl;
cout << " The largest number is : " << largest <<
endl;
cout << " The smallest number is : " << smallest
<< endl;
return 0;
}
#output
#if you have any doubts comment below...if you like give thumbs
up..