Sponsored Content
Top Forums Programming Need help with this c++ source code! DOnt understand what some stuff mean. Post 302512304 by orszhak on Saturday 9th of April 2011 10:31:26 AM
Old 04-09-2011
Question Need help with this c++ source code! Dont understand what some of the syntax means.

Okay so I am just starting programming c++. I just started started to red "C++ for Dummies yesterday and theres a lot of things I do not understand from this book and this source code especially. I will first post the full source code and then post questions about certain thing, usually what they do and how they help. Anyways here it is! (I understand there are comments yet I still don't understand some stuff Smilie, sorry)

Code:
 
//
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// enter the temperature in Celsius
int celsius;
cout << “Enter the temperature in Celsius:”;
cin >> celsius;
// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;
// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;
// output the results (followed by a NewLine)
cout << “Fahrenheit value is:”;
cout << fahrenheit << endl;
// wait until user is ready before terminating program
// to allow the user to see the program results
system(“PAUSE”);
return 0;
}

Okay so these are the things I do not undersand. In these lines, i understand it declares a variable and names it "factor" but I dont understand why on the next line it says "factor = 212 - 32;" what does the equals sign mean and what do the integers 212 and 32 do? also what the minus sign do. I think this is an expression but i dont understand it. Do I need it? Please help! Explain it in non geeky please guys! I am pretty newbie. Here is the source code:

Code:
 int factor;
factor = 212 - 32;

Next would be this expression and how it works. Is this the formula to convert Celsius to Fahrenheit? Please explain everything and what ALL things do. equals sign, etc. Non geeky please I am pretty newbie right now.

Code:
fahrenheit = factor * celsius/100 + 32;

Well that's it for now! I hope you wizards answer this soon. I will continue to read and continue to stumble countless times. Anyways guys have a good day! Smilie

Last edited by orszhak; 04-09-2011 at 03:53 PM.. Reason: mistakes made
 

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

dont understand

i'm trying to learn unix and i posted a question and what i was typing from school. i can't figure it out. how am i supposed to learn , when i get shutdown by an admin. for posting a homework question. doesn't make any sense. its a dumb rule. thanks for helping (4 Replies)
Discussion started by: AtomJ22
4 Replies

2. UNIX for Advanced & Expert Users

Code Understand ?

Hey, Could you explain me what this code is doing ? For example: $i has value 9 $1 is the name of the file say FILEBkUp while do if $1.`/bin/expr $i - 1` ] then mv -f $1.`/bin/expr $i - 1` $1.$i fi i=`/bin/expr $i - 1` done Thanks... (2 Replies)
Discussion started by: varungupta
2 Replies

3. Shell Programming and Scripting

bash shell: 'exec', 'eval', 'source' - looking for help to understand

Hi, experts. Whould anybody clear explay me difference and usage of these 3 commands (particulary in bash) : exec eval source I've tryed to read the manual pages but did not get much. Also could not get something useful from Google search - just so much and so not exactly, that is... (3 Replies)
Discussion started by: alex_5161
3 Replies

4. Shell Programming and Scripting

Need help to understand Awk code.

Hi Guys, Can someone please explain this code to me. I could figure out it's adding and comparing two fields but I am not sure which ones. sort -t"|" -k3.1 /tmp/mpcashqc.xtr| awk -F"|" '{CHECKAMT+=$3;BATCHTOT=$4;\ items++}END{for(i in CHECKAMT) if (CHECKAMT!=BATCHTOT)... (6 Replies)
Discussion started by: nua7
6 Replies

5. Shell Programming and Scripting

help can't understand the code

Hi All, Good day, i'm just wondering what is the meaning of this code? COUNT_EXTRACTED_FILE=`${ECHO_CMD} "${SE_IN_PATH}${SE_IN_FILE}" | ${AWK_CMD} -F"__" '{print $2}'` Thanks, -niks(newbie) (2 Replies)
Discussion started by: nikki1200
2 Replies

6. Programming

Breakpoints dont work in Codeblocks, code does not build

Hey so I've written a program and it crashes every time I run it. I tried placing breakpoints to see what was going but to my surprise they do not work! I've placed them anywhere and they do not stop the execution of the program. In fact if I add code and hit rebuild it doesn't even build that... (1 Reply)
Discussion started by: Cambria
1 Replies

7. UNIX for Dummies Questions & Answers

help me to understand this code

Hi guys can you please help me to understand this code . tmpArray=(${line//=/ }) Please next time open a new thread in the appropriate forum and use code tags (6 Replies)
Discussion started by: sandhya.gilla
6 Replies

8. Programming

Help me to understand strange 'typedef ... ' in some source...

Working on some source I've found some strange declaration in included header file. I am looking for someone's help to understand me that syntax's, as it is fine (it is compiled without any complain,) but for me it seems out of any sense! Acctually, it warning by CC compiler: " Warning: Implicit... (1 Reply)
Discussion started by: alex_5161
1 Replies

9. UNIX for Beginners Questions & Answers

Bad substituion error : Dont understand why

Hi Folks - I'm getting the following error message when executing my script: $ chmod +x Winexe_Admin.sh $ ./Winexe_Admin.sh Script Name: Winexe_Admin.sh Script Name without EXT: Winexe_Admin ./Winexe_Admin.sh: line 43: ${_MAINPATH}${_LOGPATH}${LOGPATH$}${_YEAR}_${_MONTH}${_DAY}: bad... (2 Replies)
Discussion started by: SIMMS7400
2 Replies
ACPI(1) 						      General Commands Manual							   ACPI(1)

NAME
acpi - Shows battery status and other ACPI information SYNOPSIS
acpi [options] DESCRIPTION
acpi Shows information from the /proc or the /sys filesystem, such as battery status or thermal information. OPTIONS
-b | --battery show battery information -a | --ac-adapter show ac adapter information -t | --thermal show thermal information -c | --cooling show cooling device information -V | --everything show every device, overrides above options -s | --show-empty show non-operational devices -i | --details show additional details if available: * battery capacity information * temperature trip points -f | --fahrenheit use fahrenheit as the temperature unit instead of default celsius -k | --kelvin use kelvin as the temperature unit instead of default celsius -p | --proc use the old /proc interface, default is the new /sys one -d | --directory <dir> path to ACPI info (either /proc/acpi or /sys/class) -h | --help display help and exit -v | --version output version information and exit AUTHOR
The original version of this manual page was written by Paul Telford <pxt@debian.org> for the Debian system. Newer additions were done by Michael Meskes <meskes@debian.org>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU GPL. ACPI(1)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy