Kasus 4.8

Pertanyaan :

#include <iostream>
#include <conio.h>
#include <string>
#include <math.h>
#include <cstdlib>

using namespace std;
int main(){
   int hasil;
   int i;
   int y;
   int x;

   i = 1;
   hasil = 0;
   cout << "Masukkan bilangan yang akan di kalikan = ";
   cin >> x;
   cout << "Akan dikalikan dengan = ";
   cin >> y;
  
   while (!(i>(abs(y)))){
      hasil = hasil + x;
      i =i+1;
   }
   if (y<0){
      cout << x << " x " << y << " = -" << hasil << endl;
   }
   else{
      cout << x << " x " << y << " = " << hasil << endl;
   }
   getch();

}


Output :


Raptor :





Share this

Related Posts

Previous
Next Post »

1 komentar:

komentar
20 March 2016 at 02:30 delete

kurang ngerti dengan pemrograman kaya gini

Reply
avatar