Computing.Net > Forums > Programming > C++:Useing mathmatical functions

C++:Useing mathmatical functions

Reply to Message Icon

Original Message
Name: NiGhTsHaDe
Date: March 2, 2007 at 14:58:58 Pacific
Subject: C++:Useing mathmatical functions
OS: Dark
CPU/Ram: Hyper
Model/Manufacturer: DarkForest
Comment:

Im trying to preform mathimatical functions on variables in c++ but cant seem to get it to work some advice? heres my code

#include <iostream>

using namespace std;

int main()
{
int thisisanumber = thisisanumber - 10; //int says that thisisanumber is an integer
//if the user try's to put a decimal the . will be ignored

cout<<"Please enter your age: ";
cin>> thisisanumber; //cin says that a value goes into thisisanumber the user
// a number the user must press enter
cin.ignore();//you type input into program it takes enter key don't need this
cout<<"Your age is: "<< thisisanumber <<"\n";
//you must seperate string literals(strings enclosed in quotation marks) and
//variables useing <<<<<<
cin.get();
}


Report Offensive Message For Removal


Response Number 1
Name: cup
Date: March 3, 2007 at 11:34:54 Pacific
Reply: (edit)

The first line of code doesn't make sense. Try

int thisisanumber; //int says that thisisanumber is an integer


Report Offensive Follow Up For Removal

Response Number 2
Name: ipartyin247
Date: March 16, 2007 at 08:22:05 Pacific
Reply: (edit)

if you want the -10
int thisisanumber;
int newnumber = thisisanumber-10;

-CG


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: C++:Useing mathmatical functions

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge