Breaking News
Loading...
Sabtu, 19 Maret 2016

Operasi Aritmatika



1.       Operasi aritmatika dengan menginputkan dengan keyboard
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
                float a,b,c,nilai_jml,nilai_kli,nilai_krg,nilai_bgi;
   
    cout<<"Masukkan nilai A = ";
    cin>>a;
    cout<<"Masukkan nilai B = ";
    cin >>b;
    cout<<"Masukkan nilai C = ";
    cin >>c;
   
    nilai_jml=a+b+c;
    nilai_kli=a*b*c;
    nilai_bgi=(a/b)/c;
    nilai_krg=a-b-c;
   
   
   
    cout<<"penjumlahan a + b + c\t= "<<a<< "+" <<b<< "+" <<c<< "="<<nilai_jml<<endl;
    cout<<"perkalian a x b x c\t= "<<a<< "x" <<b<< "x" <<c<< "="<<nilai_kli<<endl;
    cout<<"pengurangan a - b - c\t= "<<a<< "-" <<b<< "-" <<c<< "="<<nilai_krg<<endl;
    cout<<"pembagian a : b : c\t= "<<a<< ":" <<b<< ":" <<c<< "="<<nilai_bgi<<endl;

                return 0;
}
Hasil Compile-nya :
 

0 komentar:

Posting Komentar

Copyright © 2014 My Blog My Adventure All Right Reserved