Google Answers Logo
View Question
Q: Definition and Meaning of C++ Items ( Answered 5 out of 5 stars,   2 Comments )
Subject: Definition and Meaning of C++ Items
Category: Computers > Programming
Asked by: doylexx-ga
List Price: $20.00
Posted: 21 Apr 2006 08:58 PDT
Expires: 21 May 2006 08:58 PDT
Question ID: 721343
(In C++ Programming define the below bullets and their meaning:

What is int i, j; 
What is char c:
What is float x
std::cin>> integer1;
cout<<i << "," << j << ", " << x << "\n";

Request for Question Clarification by hammer-ga on 21 Apr 2006 09:23 PDT
I understand the lines of code, but I'm not sure what you are asking
for. Could you clarify what you need? Are you just looking for an
explanation of what each line does?

- Hammer
Subject: Re: Definition and Meaning of C++ Items
Answered By: hammer-ga on 21 Apr 2006 18:15 PDT
Rated:5 out of 5 stars

Below is an explantion of each point you list in your question.

[[ What is int i, j; ]]

Declares two variables named i and j, both of type int (Integer).

[[ What is char c: ]]

Declares a variable named c of type char, which holds a single character.

[[ What is float x ]]

Declares a variable named x of type float (floating point number).

[[ i=4 ]]

Assigns the value 4 to the variable named i.

[[ j=i+7; ]]

Assigns the current value of the variable named i plus 7 to the
variable called j. For example, if the current value of i is 4, then j
would equal 11 after this line runs.

[[ x=9.087 ]]

Assigns the value 9.087 to the variable named x.

[[ x=x*12.3 ]]

Multiplies the current value of the variable named x by 12.3 and
assigns the result back to the variable called x.

[[ std::cin>> integer1; ]]

Uses the stream extraction operator (>>) to place the value typed by
the user in a variable named integer1. std::cin means standard input.

[[ cout<<i << "," << j << ", " << x << "\n"; ]]

Uses the stream insertion operator (<<) to send the expression(s) on
the right to standard output (cout). The result sent to standard
output would be the value of i followed by a comma and a space,
followed by the value of j followed by a comma and a space followed by
the value of x followed by a newline (\n). So if the variables are set
as follows:

i = 5
j = 10
x = 9.087

...then the output would be

5, 10, 9.087 (newline)

Please ask for clarification if you need additional information on these concepts.

- Hammer

Additional Info
An explanation of variable types like int, char and float, variable
declarations and assignments.

An introduction to stream operators
doylexx-ga rated this answer:5 out of 5 stars
Exactly what I needed! Many thanks!

Subject: Re: Definition and Meaning of C++ Items
From: mootothemax-ga on 21 Apr 2006 09:21 PDT
Do you mean what will the program output be? If so, I'm 99% sure it
wouldn't compile, due to this line:

std::cin>> integer1;

This is because integer1 is not defined anywhere.

Could you clarify the question?
Subject: Re: Definition and Meaning of C++ Items
From: doylexx-ga on 22 Apr 2006 11:21 PDT
This is my second class in C++ and of course I ama beginner. The
instructor would like us to comment in the (//) are in the program of
what the following items are and their functions:

#include <iostream>  					//

int main()
	int integer1, integer2, sum;			//

	std::cout  << "Enter first integer\n";		//
	std::cin >> integer1;    //
	std::cout << "Enter second integer\n"; 	//
	std::cin >> integer2;   				//
	sum = integer1 + integer2;  			//
	std::cout << "Sum is " << sum << std::endl;  //

	return 0;  					//

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy