How to using "IF" in c++

"If" is usually used to returns one value if a specified condition evaluates to TRUE, or another value if it evaluates to FALSE. See this example below :
#include<iostream.h>
#include<conio.h>
void main() {
int nilai;
cout <<"Nilai : ";
cin>>nilai;
if(nilai>80){
    cout <<"Nilainya A";
   } else if(nilai> 70) {
   cout <<"Nilainya B";
   } else if (nilai> 60){
   cout <<"Nilainya C";
   } else {
   cout <<"Nilainya D";
   }
   getch();
}
Previous
Next Post »