23.1.23020056. Generisati 3 dvocifrena broja. Naći sumu parnih.
Opis rješenja:
Listing programa:
//23020056
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
srand(time(NULL));
int a=rand()%89+10,b=rand()%89+10,c=rand()%89+10;
int suma=0;
cout<<a<<" "<<b<<" "<<c<<endl;
if(a % 2 == 0){
suma=suma+a;
}
if(b % 2 == 0){
suma=suma+b;
}
if(c % 2 == 0){
suma=suma+c;
}
else if(suma == 0){
cout<<"Nema parnih brojeva"<<endl;
}
cout<<"Suma parnih je: "<<suma<<endl;
return 0;
}
Ispis na ekranu:
Riješeni zadaci Index
|