#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) {
int a,b,hsl=0;
cout<<"Program perkalian dengan metode penjumlahan"<<endl;
cout<<"Masukan nilai a = "; cin>>a;
cout<<"Masukan nilai b = "; cin>>b;
cout<<" "<<a<<" x "<<b<<endl;
for(int i=1;i<=b;i++)
{ hsl=hsl+a;
}
if(b<0)
cout<<"Hasil perkalian = "<<-1*hsl;
else
cout<<"Hasil perkalian = "<<hsl;
return 0;
}
Program raptornya
/* 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) {
int a,b,hsl=0;
cout<<"Program perkalian dengan metode penjumlahan"<<endl;
cout<<"Masukan nilai a = "; cin>>a;
cout<<"Masukan nilai b = "; cin>>b;
cout<<" "<<a<<" x "<<b<<endl;
for(int i=1;i<=b;i++)
{ hsl=hsl+a;
}
if(b<0)
cout<<"Hasil perkalian = "<<-1*hsl;
else
cout<<"Hasil perkalian = "<<hsl;
return 0;
}
Program raptornya
Comments
Post a Comment