| Tariqsal (2) | |
|
hello everybody i just started one day ago my course in C++ can any body help me with this code it keeps tell me that there is error but icant find it #include <iostream> using namespace std; int main () {int c; cout << " enter the Temp in Celisus " << endl; cin >> c ; Ye= (1.8*c); Fr= (Ye + 32); cout << " the Temp in Ferhenheit = " << Fr << endl; cout <<"this Pro was desinged by Tariq Co" << endl; cout <<"PPU University" << endl; system ("pause"); return 0; } | |
|
|
|
| skarla (243) | |
|
you have not decalred the "YE" aNd "FR". put: int Ye,Fr; | |
|
|
|
| devonrevenge (668) | |
|
int something; is like an empty box i have just created, now i can use something as much as i like something = 4; cout << something cout <<something+somthing+1; | |
|
|
|
| Moschops (5959) | ||
It's not empty. There is a value in there already. You just don't know what it is until you check. | ||
|
Last edited on
|
||
| devonrevenge (668) | |
| unwanted junk!? | |
|
|
|
| Moschops (5959) | |
| Yup. | |
|
|
|
| Zereo (181) | |
Also int would not be the proper choice for Fr and Ye since he is doing 1.8 * c. So it should be a double Fr; and double Ye; variable instead
| |
|
|
|
| Bartek (7) | |||
|
Hi Tariqsal, - "system ("PAUSE");" needs "windows.h"; Next time organize your code, please. ... you can optimize this, like this:
BTW.: "system ("PAUSE");" isn't the best solution. | |||
|
Last edited on
|
|||
| Kiklop (2) | |
|
Hello Bartek, I read your reply and am curious about 2 things: 1) Why/how does " system ("PAUSE"); " need <windows.h>? I've always used system pause without it and it worked fine (to my knowledge, that is) 2) Do you mean that system pause is not a good solution because it might/will not work on linux etc. , or for some other reason? I hope I don't come out as rude or annoying, I'm a beginner and just want to learn. Thank you in advance! | |
|
|
|
| Bartek (7) | |
|
- When I try to run a program with 'system();' without 'windows.h' or 'cstdlib' (of which system is a part of) it can't work... but I could be wrong. - When you utilise 'system();' your program can be marked as a virus. | |
|
Last edited on
|
|
| Kiklop (2) | |
|
Op! I was just getting back to erase or edit the comment because I have just found an explanation on another thread. Anthough, thank you! Funny, I'm on the first year of Computer Science and none of the professors ever mentioned this. Kind of feels like they should though, 'cause it already got into my 'routine' to use it.. | |
|
|
|
| Zereo (181) | |
| You will learn a lot of professors teach bad habits. But hey it might give you some extra credit if you go to your professor and say "hey I shouldn't be using system() anything because of this this and this ;p | |
|
|
|
| Volatile Pulse (1329) | |
|
You, and probably the rest of your classmates and professors are likely using Microsoft Visual Studio to write your code it. It automatically includes certain functions, system being the most common, so that you don't have to add an extra header file. This is yet another reason that I hate MSVC++. The reason he said that system isn't good to use is because of known vulnerabilities with it. Please refer to this for further details: http://cplusplus.com/articles/j3wTURfi/ (there is also possible alternatives to using the system function located here). Typically it's better to use something similar to the cin.ignore() trick, or something that won't put your system into any danger. If you really want to know proper ways to "pause" your code, have a look at the second stickied thread on this forum. There are also numerous threads floating around about how to "pause" your code. Just do some research. | |
|
|
|