#include <iostream.h>
#include <conio.h>
void main ()
{
int i;
for (i=0;i<10;i++)
{
if (i==4) continue;
cout << "bilangan" << i <<endl;
if (i==6) break;
}
getch () ;
}
Selasa, 23 Oktober 2012
CC++ BREAK
#include <iostream.h>
#include <conio.h>
void main ()
{
int i;
for (i=0;i<10;i++)
{
if (i==4) continue;
cout << "bilangan" << i <<endl;
if (i==6) break;
}
getch () ;
}
#include <conio.h>
void main ()
{
int i;
for (i=0;i<10;i++)
{
if (i==4) continue;
cout << "bilangan" << i <<endl;
if (i==6) break;
}
getch () ;
}
Senin, 22 Oktober 2012
C++ IF
# include <iostream.h>
# include <conio.h>
void main ()
{
int usia;
cout << " Berapa usia mu ? ";
cin >> usia;
if (usia < 17)
cout << " Anda tidak boleh menonton :( " << endl;
else
cout << " Selamat menonton ;) " << endl;
getch () ;
}
# include <conio.h>
void main ()
{
int usia;
cout << " Berapa usia mu ? ";
cin >> usia;
if (usia < 17)
cout << " Anda tidak boleh menonton :( " << endl;
else
cout << " Selamat menonton ;) " << endl;
getch () ;
}
C++ SWICTH
#include <iostream.h>
#include <conio.h>
void main ()
{
int nilai;
cout << "masukan nilai test : ";
cin >> nilai;
switch (nilai/10)
{
case 10:
case 9:
case 8:
cout << 'A' <<endl;break;
case 7:
cout << 'B' <<endl;break;
case 6:
case 5:
cout << 'C' <<endl;break;
case 4:
case 3:
cout << 'D' <<endl;break;
case 2:
case 1:
case 0:
cout << 'E' <<endl;break;
default :
cout << "salah,nilai diluar jangkauan ." <<endl;
}
getch();
}
#include <conio.h>
void main ()
{
int nilai;
cout << "masukan nilai test : ";
cin >> nilai;
switch (nilai/10)
{
case 10:
case 9:
case 8:
cout << 'A' <<endl;break;
case 7:
cout << 'B' <<endl;break;
case 6:
case 5:
cout << 'C' <<endl;break;
case 4:
case 3:
cout << 'D' <<endl;break;
case 2:
case 1:
case 0:
cout << 'E' <<endl;break;
default :
cout << "salah,nilai diluar jangkauan ." <<endl;
}
getch();
}
C++ Fungsi
#include <iostream.h>
#include <conio.h>
double hasil (int A, int B) ;
void main ()
{
int x,y ;
double z;
cout << "masukkan Nilai x : ";
cin >> x;
cout << "masukkan Nilai y : ";
cin >> y;
z = hasil (x,y) ;
cout << "hasil perkalian = ";
cout << x << "x" << y << " = " << z;
getch ();
}
double hasil (int A, int B)
{
return ( A * B);
}
#include <conio.h>
double hasil (int A, int B) ;
void main ()
{
int x,y ;
double z;
cout << "masukkan Nilai x : ";
cin >> x;
cout << "masukkan Nilai y : ";
cin >> y;
z = hasil (x,y) ;
cout << "hasil perkalian = ";
cout << x << "x" << y << " = " << z;
getch ();
}
double hasil (int A, int B)
{
return ( A * B);
}
Langganan:
Postingan (Atom)