Jumat, 02 September 2016

Operator Unary Pada C++


#include<iostream.h>
#include<conio.h>

main()
{
int x;
float y;

x = +5;
y = -2.12;

cout<<"\n Nilai x : "<<x;
cout<<"\n Nilai y : "<<y<<endl;

x=-x; //Merubah Nilai Menjadi Negatif
y=-y;

cout<<"\n Nilai x : "<<x;
cout<<"\n Nilai y : "<<y<<endl;

//Operasi increment, x = x + 1;
x++;
//Operasi decrement, y = y - 1;
y--;

cout<<"\n Nilai x : "<<x<<" y : "<<y;

getch();
}


Output :


0 komentar:

Posting Komentar