Advertisement
dirtydevil123

grading (if /else)

Jul 3rd, 2021
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double marks;
  8.     cin>>marks;
  9.  
  10.     //approach-1
  11.     if(marks>=80) {
  12.         cout<<"A\n";
  13.     }
  14.     if(marks>=60 && marks<80) {
  15.         cout<<"B\n";
  16.     }
  17.     if(marks>=40 && marks<60) {
  18.         cout<<"C\n";
  19.     }
  20.     if(marks<40) {
  21.         cout<<"F\n";
  22.     }
  23.  
  24.     //approach-2
  25.     if(marks>=80) {
  26.         cout<<"A\n";
  27.     }
  28.     else if(marks>=60) {
  29.         cout<<"B\n";
  30.     }
  31.     else if(marks>=40) {
  32.         cout<<"C\n";
  33.     }
  34.     else {
  35.         cout<<"F\n";
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement