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
Device::USB::PCSensor::HidTEMPer::Sensor(3pm)		User Contributed Perl Documentation	     Device::USB::PCSensor::HidTEMPer::Sensor(3pm)

       Device::USB::PCSensor::HidTEMPer::Sensor - Generic sensor class

VERSION
Version 0.02 SYNOPSIS
None DESCRIPTION
This module contains a generic class that all HidTEMPer sensors should inherit from keeping the implemented methods consistent, and making it possible to use the same code to contact every supported device. CONSTANTS o MAX_TEMPERATURE The highest temperature(Celsius) this sensor can detect. o MIN_TEMPERATURE The lowest temperature(Celsius) this sensor can detect. METHODS o new( $device ) Generic initializing method, creating a sensor object. Input parameter $device = A pre-initialized Device::USB::PCSensor::HidTEMPer::Device that the sensor is connected to. This device will be used to handle communication. o fahrenheit() Reads the current temperature and returns the corresponding value in fahrenheit degrees. o max() Returns the highest temperature(Celsius) the sensor can detect. o min() Returns the lowest temperature(Celsius) the sensor can detect. o celsius() Empty method that should be implemented in each sensor, returing the current degrees in celsius. DEPENDENCIES
This module internally includes and takes use of the following packages: use Scalar::Util qw/ weaken /; This module uses the strict and warning pragmas. BUGS
Please report any bugs or missing features using the CPAN RT tool. FOR MORE INFORMATION
None AUTHOR
Magnus Sulland < msulland@cpan.org > ACKNOWLEDGEMENTS
None COPYRIGHT &; LICENSE Copyright (c) 2010 Magnus Sulland This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-07-24 Device::USB::PCSensor::HidTEMPer::Sensor(3pm)
All times are GMT -4. The time now is 05:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy