Tugas Alpro PPT Minggu ke 2 Kasus 2.6

Setiap bilangan bulat selalu bisa ditulis dalam
     Bentuk : m = q.n + r

  • Dengan n < m, q adalah kuosen dan r adalah residu (sisa)
  • Buatlah algoritma untuk merepresentasikan m dan dalam bentuk m = q.n + r. Sebagai
  • Contoh :
  • Integer m = 73 dan n = 7 dapat ditulis sebagai 73 = 10*7 + 3, yaitu r = 3.
Logikanya menggunakan raptor
Program C++
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    int m,n,r;
    float q;
    cout<<"masukkan nilai m = ";cin>>m;
    cout<<"masukkan niali n = ";cin>>n;
    q=m/n;
    r=m%n;
    cout<<m<<"="<<q<<"*"<<n<<"+"<<r;
    return 0;
}


Share this:

ABOUT THE AUTHOR

Ceyron Louis

A web designer from India. And then you write some more information about yourself like this to fill out the space that is left.

0 komentar:

Posting Komentar