...

View Full Version : remainder output



joven
09-05-2009, 04:40 PM
#include <cstdlib>
#include <iostream.h>



void main()
{
double num;
double num2;

cout<<" Good Day!!\n";

cout<<"Please enter a number = ";
cin>>num;
cout<<"Another one to be divided= ";
cin>>num2;
cout<<"answer is = "<<num / num2;
cout<<"\n" ;

}

my prob is i want to the remainder only.. ex. 18/5 then the remainder is 3.. can someone revise my code??tnx guys:thumbsup:

BWiz
09-05-2009, 05:07 PM
Use the modulus operator (http://www.cprogramming.com/tutorial/modulus.html).



int main(void) {
int rem = 18%5;
cout << rem << endl;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum