Noxious020189
03-04-2006, 04:41 PM
I know I posted about the <iostream> just the other day (yesterday), but as I said there it's just for the <iostream>, so I thought I would start a thread so that I learn as I go. I'm just trying to make simple programs, and I thought it would be nice if I could get some help on what to do when I'm stuck, and an explination would be nice to of why it's there and how it works. I do look up stuff in both "C++ For Dummies" (I know it's sad, but I bought this book when I had 56K and at a stupid age where I thought I knew everything). I also have the internet to look things up, but I need help from forums sometimes because users tend to explian the way I understand. So let me get this started:
First off:
using namespace std; ^What dose that do. I used it, and it made my code work.
Second off:
//PROGRAM WRITTER: Chris Kaliszewski
//PROGRAM NAME: Test Project
//PROGRAM START DATE: 03/03/06
//PROGRAM END DATE: TBA
#include<iostream>
using namespace std;
void main()
{
int No_of_Items, Per_Tax; //Declaring "Number of Items" and "Percentage of Tax" as an integer
cout <<"How many items will you be buying? "; //Asking "How many items will be bought"
cin >>No_of_Items; //Hold value for the "Number of Items"
cout <<"How much is tax? "; //Asking "How much tax is"
cin >>Per_Tax; //Hold value for the "Percentage of Tax"
double Real_Tax; //Declaring "Decimal Percentage" as a double
char Yes_No;
Real_Tax = Per_Tax * .01; //Multiplying Per_Tax by one tenth to get the "Decimal Percentage"
system("cls"); //Clears the screen
cout <<"Number of items: "<<No_of_Items<<'\n'; //Informs the user of what they entered for "Number of Items"
cout <<"Percentage of tax: "<<Per_Tax<<"\n\n"; //Informs the user of what they entered for "Percentage of Tax"
cout <<"Is that the correct data? (Please type Y or N) "; //Asking if the information is right
cin >>Yes_No; //Hold value for the "Yes or No"
cout <<"\n\n"; //New Lines(2)
return 0;
} ^Why won't that return work? Down below is what error I get. I looked up return, and by my understanding if I use "return 0" then it should return my code back up to the "void main()" function.
ERROR:
1>------ Build started: Project: Tax Calculator, Configuration: Debug Win32 ------
1>Compiling...
1>Tax Calculator.cpp
1>c:\documents and settings\owner\my documents\visual studio 2005\projects\tax calculator\tax calculator\tax calculator.cpp(28) : error C2562: 'main' : 'void' function returning a value
1> c:\documents and settings\owner\my documents\visual studio 2005\projects\tax calculator\tax calculator\tax calculator.cpp(7) : see declaration of 'main'
1>Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\Tax Calculator\Tax Calculator\Debug\BuildLog.htm"
1>Tax Calculator - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
First off:
using namespace std; ^What dose that do. I used it, and it made my code work.
Second off:
//PROGRAM WRITTER: Chris Kaliszewski
//PROGRAM NAME: Test Project
//PROGRAM START DATE: 03/03/06
//PROGRAM END DATE: TBA
#include<iostream>
using namespace std;
void main()
{
int No_of_Items, Per_Tax; //Declaring "Number of Items" and "Percentage of Tax" as an integer
cout <<"How many items will you be buying? "; //Asking "How many items will be bought"
cin >>No_of_Items; //Hold value for the "Number of Items"
cout <<"How much is tax? "; //Asking "How much tax is"
cin >>Per_Tax; //Hold value for the "Percentage of Tax"
double Real_Tax; //Declaring "Decimal Percentage" as a double
char Yes_No;
Real_Tax = Per_Tax * .01; //Multiplying Per_Tax by one tenth to get the "Decimal Percentage"
system("cls"); //Clears the screen
cout <<"Number of items: "<<No_of_Items<<'\n'; //Informs the user of what they entered for "Number of Items"
cout <<"Percentage of tax: "<<Per_Tax<<"\n\n"; //Informs the user of what they entered for "Percentage of Tax"
cout <<"Is that the correct data? (Please type Y or N) "; //Asking if the information is right
cin >>Yes_No; //Hold value for the "Yes or No"
cout <<"\n\n"; //New Lines(2)
return 0;
} ^Why won't that return work? Down below is what error I get. I looked up return, and by my understanding if I use "return 0" then it should return my code back up to the "void main()" function.
ERROR:
1>------ Build started: Project: Tax Calculator, Configuration: Debug Win32 ------
1>Compiling...
1>Tax Calculator.cpp
1>c:\documents and settings\owner\my documents\visual studio 2005\projects\tax calculator\tax calculator\tax calculator.cpp(28) : error C2562: 'main' : 'void' function returning a value
1> c:\documents and settings\owner\my documents\visual studio 2005\projects\tax calculator\tax calculator\tax calculator.cpp(7) : see declaration of 'main'
1>Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\Tax Calculator\Tax Calculator\Debug\BuildLog.htm"
1>Tax Calculator - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========