2 min read
Well, here’s my program Fun With number, I only have to read the chapter 2 of the book “How to think like a computer scientist” by Allen B. Downey. And rember somethings, because it’s very similar to program in C#, at least that I learned last semester. #WSQ03
and here’s the code:
#include <iostream>
using namespace std;
int main(){
int n1,n2,suma,dif,divi,multi,modulo;
cout <<“nGive a number: “;
cin >>n1;
cout<<“nGive another number: “;
cin>>n2;
suma=n1+n2;
dif=n1-n2;
divi=n1/n2;
multi=n1*n2;
modulo=n1%n2;
cout<<“nThe sum of ” <<n1<< ” + ” <<n2<< ” = ” <<suma<< endl;
cout<<“nThe difference of ” <<n1<< ” – ” <<n2<< ” = ” <<dif<< endl;
cout<<“nThe division of ” <<n1<< ” / ” <<n2<< ” = ” <<divi<< endl;
cout<<“nThe multiplication of ” <<n1<< ” * ” <<n2<< ” = ” <<multi<< endl;
cout<<“nThe module of ” <<n1<< ” MOD ” <<n2<< ” = ” <<modulo<< endl;
return 0;
}
Fun With Numbers #WSQ03 by Samir Godinez is licensed under a Creative Commons Attribution 4.0 International License.