23.1.23020059. Generisati 3 dvocifrena broja. Naći sumu parnih i sumu neparnih.

Opis rješenja:

Listing programa:

//23020059
#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 suma1=0,suma2=0;
	cout<<a<<" "<<b<<" "<<c<<endl;
	
	if(a % 2 == 0){
		suma1=suma1+a;
	}
		else if(a % 2 != 0){
			suma2=suma2+a;
		}
	if(b % 2 == 0){
		suma1=suma1+b;
	}
		else if(b % 2 != 0){
			suma2=suma2+b;
		}
	if(c % 2 == 0){
		suma1=suma1+c;
	}
		else if(c % 2 != 0){
			suma2=suma2+c;
		}
	cout<<"Suma parnih: "<<suma1<<endl;
	cout<<"Suma neparnih: "<<suma2<<endl;
	return 0;
}

Ispis na ekranu:

Riješeni zadaci    Index