---------------------------------------------------------------------------------------------------
CONTOH PRINTF PADA C++
---------------------------------------------------------------------------------------------------
/*program contoh_printf.cpp*/
#include<stdio.h>
#include<conio.h>
main()
{
int a;
unsigned int b;
float c;
char d,*e;
a=-10;
b=15;
c=65.75;
d='A';
e="bahasa c++";
printf("nilai integer =%d\n",a);
printf("nilai int tak bertanda =%u\n",b);
printf("nilai floting point =%f\n",c);
printf("nilai floting point eksponensial =%e\n",c);
printf("nilai karakter =%c\n",d);
printf("nilai string=%s\n",e);
printf("nilai pointer =%p\n",&e);
getch();
}
---------------------------------------------------------------------------------------------------
PROGRAM CONTOH COLT
---------------------------------------------------------------------------------------------------
//program contoh colt
#include<iostream.h>
#include<conio.h>
main()
{
int jumlah,bil1, bil2;
float rata;
cout<<"masukan bilangan I:"; cin>>bil1,
cout<<"masukan bilangan II:";cin>>bil2;
jumlah=bil1+bil2;
rata=jumlah/2;
cout<<"\n";
cout<<"hasil penjumlahan " <<bil1<< " dan " <<bil2<<" adalah "<<jumlah<<endl;
cout<<"rata2nya adalah :"<<rata;
getch();
}
---------------------------------------------------------------------------------------------------
CONTOH PROGRAM DECREMENT
---------------------------------------------------------------------------------------------------
CONTOH 1
INCRENMENT--
---------------------------------------------------------------------------------------------------
/*program decrement*/
#include<stdio.h>
#include<conio.h>
main()
{
int x=10;
x=x--;
printf("nilai x=%d\n",x);
x=--x;
printf("nilai x=%d\n",x);
getch();
}
---------------------------------------------------------------------------------------------------
INCREMENT ++
---------------------------------------------------------------------------------------------------
/*program increment*/
#include<stdio.h>
#include<conio.h>
main()
{
int x=10;
x=x++;
printf("nilai x=%d\n",x);
x=++x;
printf("nilai x=%d\n",x);
getch();
}
---------------------------------------------------------------------------------------------------
CONTOH 2 INCRENMENT A,B,C
---------------------------------------------------------------------------------------------------
/*program increment*/
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
a=5;
b=5;
c= a+b++;
printf("nilai c=%d\n",c);
c= a+ ++b;
printf("nilai c= %d\n",c);
getch();
}
---------------------------------------------------------------------------------------------------
terimakasih telah berkunjung silahkan dikomentar dan ikuti blog ini.
Manhalawa
Mei 19, 2017
Admin
Bandung Indonesia
CONTOH PROGRAM : PRINTF, COLT DAN DECREMENT PADA C++
---------------------------------------------------------------------------------------------------
CONTOH PRINTF PADA C++
---------------------------------------------------------------------------------------------------
/*program contoh_printf.cpp*/
#include<stdio.h>
#include<conio.h>
main()
{
int a;
unsigned int b;
float c;
char d,*e;
a=-10;
b=15;
c=65.75;
d='A';
e="bahasa c++";
printf("nilai integer =%d\n",a);
printf("nilai int tak bertanda =%u\n",b);
printf("nilai floting point =%f\n",c);
printf("nilai floting point eksponensial =%e\n",c);
printf("nilai karakter =%c\n",d);
printf("nilai string=%s\n",e);
printf("nilai pointer =%p\n",&e);
getch();
}
---------------------------------------------------------------------------------------------------
PROGRAM CONTOH COLT
---------------------------------------------------------------------------------------------------
//program contoh colt
#include<iostream.h>
#include<conio.h>
main()
{
int jumlah,bil1, bil2;
float rata;
cout<<"masukan bilangan I:"; cin>>bil1,
cout<<"masukan bilangan II:";cin>>bil2;
jumlah=bil1+bil2;
rata=jumlah/2;
cout<<"\n";
cout<<"hasil penjumlahan " <<bil1<< " dan " <<bil2<<" adalah "<<jumlah<<endl;
cout<<"rata2nya adalah :"<<rata;
getch();
}
---------------------------------------------------------------------------------------------------
CONTOH PROGRAM DECREMENT
---------------------------------------------------------------------------------------------------
CONTOH 1
INCRENMENT--
---------------------------------------------------------------------------------------------------
/*program decrement*/
#include<stdio.h>
#include<conio.h>
main()
{
int x=10;
x=x--;
printf("nilai x=%d\n",x);
x=--x;
printf("nilai x=%d\n",x);
getch();
}
---------------------------------------------------------------------------------------------------
INCREMENT ++
---------------------------------------------------------------------------------------------------
/*program increment*/
#include<stdio.h>
#include<conio.h>
main()
{
int x=10;
x=x++;
printf("nilai x=%d\n",x);
x=++x;
printf("nilai x=%d\n",x);
getch();
}
---------------------------------------------------------------------------------------------------
CONTOH 2 INCRENMENT A,B,C
---------------------------------------------------------------------------------------------------
/*program increment*/
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
a=5;
b=5;
c= a+b++;
printf("nilai c=%d\n",c);
c= a+ ++b;
printf("nilai c= %d\n",c);
getch();
}
---------------------------------------------------------------------------------------------------
terimakasih telah berkunjung silahkan dikomentar dan ikuti blog ini.
Labels:
BAHASA PROGRAM Cpp
Thanks for reading CONTOH PROGRAM : PRINTF, COLT DAN DECREMENT PADA C++. Please share...!
0 Comment for "CONTOH PROGRAM : PRINTF, COLT DAN DECREMENT PADA C++"