Wednesday, 17 July 2013




////////mathematical operations/////////

#include "stdafx.h"
#include "stdio.h";
#include "conio.h"
#include "iostream"
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
       int n1,n2,n3;      // any 3 random numbers
       int sum;    
       int sub;          // subtraction
       int mul;         // multiplication
       float div;      // division
       int mod;       // modulus

       cout<<"Enter n1,n2,n3";
       cin>>n1>>n2>>n3;

       sum=n1+n2+n3;
       sub=n1-n2-n3;
       mul=n1*n2*n3;
       div=n1/n2/n3;
       mod=n1%n2%n3;

       cout<<n1<<"+"<<n2<<"+"<<n3<<"="<<sum<<"\n";
       cout<<n1<<"-"<<n2<<"-"<<n3<<"="<<sub<<"\n";
       cout<<n1<<"*"<<n2<<"*"<<n3<<"="<<mul<<"\n";
       cout<<n1<<"/"<<n2<<"/"<<n3<<"="<<div<<"\n";
       cout<<n1<<"%"<<n2<<"%"<<n3<<"="<<mod<<"\n";

       getch();

}
Reactions:

0 comments :

Post a Comment