Beruflich Dokumente
Kultur Dokumente
with C++
Hello World Program
Keyword Header File
#include <iostream.h>
Function Main ()
{
cout<< “Hello, World!”;
Object
}
End of Hello.cpp
function
Standard Output Stream
#include <iostream.h>
Main ()
{
cout << “My name is <name>”;
}
Several Outputs in One
Statement
#include <iostream.h>
Main ()
{
int amount = 123;
cout << “The value of amount is ” << amount <<
‘.’;
}
Standard Input Stream
#include <iostream.h>
Main ()
{
int amount;
cout << “Enter an amount…”;
cin >> amount;
cout << “The amount you entered was ” <<
amount;
}
Character Type :
A single character can be defined as a
defined as a character type of data.
Characters are usually stored in 8 bits of
internal storage. The qualifier signed or
unsigned can be explicitly applied to char.
While unsigned characters have values
between 0 and 255, signed characters have
Datatypes
Void Type :
Using void data type, we can specify the
type of a function. It is a good practice to
avoid functions that does not return any
values to the calling function.
Formatted Output
#include <iostream.h>
Main ()
{
char name[20]; //declare a new string
cout << “Enter a name…”; //request a name
cin >> name; // read the name