Translate

Showing posts with label variables. Show all posts
Showing posts with label variables. Show all posts

A Basic C++ Program – How To

————————————————————————————
#include <iostream.h> //This is a simple Hello World Program.
int main()
{
cout<<”Hello World”;
return 0;
}
————————————————————————————
//This is a simple Hello World Program.
That line of code is a comment. It is useful for com

Variables in C++

A Variable is used to declare a piece of characters. Variables are VERY important. Here is an example of a Variable:
——————————————–
#include <iostream.h>
int main()
{
int number;
number=2;
cout<<”The number is “<<number;
return 0;
}
————

Uses A Simple While Loop With compound-statement Syntax For Variable Names

#include <iostream>
using namespace std;
int main() {
int x, y;
// Get number from the keyboard and initialize x.
cout << "Enter a number and press ENTER: ";
cin >> y;
x = 1;

Simple Numeric i/o in C++

This example reads in three numbers of users and the number and average them and then print out the sum and average.


  1. #include <iostream>
  2. using namespace std;
  3. int main()

Storing Data For C++ Variables

If all you can do is print a message, C++ would not be useful. The point is usually to get new data from somewhere such as end-user input and then do something interesting with it. The operation requires a variable, this is a location where you can put the data.
You can think of variables as a magic box that holds the values​​. As a result of the program, can read, write, or modify the values ​​as needed. Next example uses a variable named ctemp and ftemp to hold Celsius and Fahrenheit values​​, respectively. How value can be put into a variable?