2. contoh program if dua else
#include<iostream>
using namespace std;
int main(){
int nilai;
cout<<"masukkan nilai anda"<<endl;
cin>>nilai;
if(nilai>85 && nilai <=100){
cout<<"maka nilainya A";
}
else if(nilai>75 && nilai<=85){
cout<<"maka nilainya B";
}
else if(nilai>55 && nilai<=75){
cout<<"maka nilainya C";
}
else if(nilai>=0 && nilai<=55){
cout<<"maka nilainya D";
}
else{
cout<<"maaf inputan anda salah";
}
}
#include<iostream>
using namespace std;
int main(){
int nilai;
cout<<"masukkan nilai anda"<<endl;
cin>>nilai;
if(nilai>85 && nilai <=100){
cout<<"maka nilainya A";
}
else if(nilai>75 && nilai<=85){
cout<<"maka nilainya B";
}
else if(nilai>55 && nilai<=75){
cout<<"maka nilainya C";
}
else if(nilai>=0 && nilai<=55){
cout<<"maka nilainya D";
}
else{
cout<<"maaf inputan anda salah";
}
}
Komentar
Posting Komentar