Sabtu, 16 Desember 2017

Cara mencari nilai rata - rata di Dev-C++

Cara mudah gimana cari nilai rata - rata mahasiswa dengan dev c++

langsung saja kita ke input sbb;

#include "iostream"
#include <windows.h>

using namespace std;
main (){
 int i,nilai[2];
 string nim [2],no[2];
 for(i=0;i<2;i++){
  cout<<"data ke :"<<i+1<<endl;
  cout<<"nim  :\t";cin>>nim[i];
  cout<<"masukan nilai :\t";cin>>nilai[i];
  cout<<endl;
 }
 cout<<"=====================================================\n";
 cout<<"NO\tNIM\t\t\tNILAI\t\tgrade\n";
 cout<<"=====================================================\n";
        for(i=0;i<2;i++){
     cout<<no[i]<<i+1<<"\t";
        cout<<nim[i]<<"\t\t";
        cout<<nilai[i]<<"\t\t";
     
        if(nilai[i]>=80)
         cout<<"A"<<endl;
        else if (nilai[i]>=60 && nilai[i]<80 )
         cout<<"B"<<endl;
        else if (nilai[i]<=60 )
         cout<<"C"<<endl;
 } 
}

maka nanti akan muncul output sbb;


Tidak ada komentar:

Posting Komentar