C + + is a programming language that is midway between the programming language level low level (machine-oriented language) and a high level. (berorirntasi in humans). C + + was created by Bjarne Stroustrup in 1983.
1. Program 1
// Exercise program 12. Program 2
#include<iostream.h>
void main()
{
cout <<”Congratulations Learning /using C + +.”;
}
//Exercise program 2
/* The sum of two numbers Program
Using variable integer */
#include<iostream.h>
void main()
{
int bil1, bil2, result;
cout << “Enter bil. 1 = “;
cin >> bil1;
cout <<”Enter bil.2 = “;
cout >> bil2;
hasil = bil1 + bil2;
cout <<”Addition results are =”<<result<<endl;
}
Basic Data Types in C + + basic data types in C + + are:
char, int, long, float, double, long double
3. Program 3
// Exercise program 3
// Knowing the size of the memory data type
#include<iostream.h>
#include<conio.h>
void main()
{
cout<<”Size char : “ << sizeof(char)<<endl;
cout<<”Size short : “ << sizeof(short)<<endl;
cout<<”Size integer : “ << sizeof(int)<<endl;
cout<<”Size long : “ << sizeof(long)<<endl;
cout<<”Size float : “ << sizeof(float)<<endl;
cout<<”Size double : “ << sizeof(double)<<endl;
}
defining the variable
Tipe_data name_variabel;
4. Program 4
// Exercise program 4
/* Example of Defining a variable of type char
and char constant assignment to a variable */
#include<iostream.h>
#include<conio.h>
void main()
{
char kar;
kar = ’A’;
clrscr();
cout<<”The contents of the variable kar = “ << kar << endl;
kar=66;
cout<<”The contents of the variable kar = “ << kar << endl;
}
5. Program 5
// Example programs using character constants with the notation \ XDD
#include<iostream.h>
#include<conio.h>
void main()
{
char ch1, ch2, ch3, ch4;
clrscr();
ch1=’\xC9’;
ch2=’\xBB’;
ch3=’\xC8’;
ch4=’\xBC’;
}
0 komentar:
Post a Comment