Seputar Dunia Teknologi Informasi

Senin, 02 Juli 2012

C++ : Program manipulator

 //Penggunaan Manipulator setbase()
# include <stdio.h>
# include <conio.h>
# include <iostream.h>
# include <iomanip.h>
main( )
{
int a = 250;
clrscr( );
cout<<"Penggunan Manipulator setbase()"<<"\n\n";
cout<<"Decimal Octal Hexadecimal"<<endl;
cout<<"----------------------------"<<"\n";
for(a=250;a<=260;a++)
{
cout<<setbase(10)<<a<<" ";
cout<<setbase(8)<<a<<" ";
cout<<setbase(16)<<a<<endl;
}
getche( );
}

2. Program Setpreci---------------------------------------------------------------------------
# include <conio.h>
# include <iostream.h>
# include <iomanip.h>
main( )
{
float a,b,c;
a = 25.23;
b = 12.54;
clrscr( );
c = a * b;
cout<<setiosflags(ios::fixed);
cout<<setprecision(1)<<c<<endl;
cout<<setprecision(2)<<c<<endl;
cout<<setprecision(3)<<c<<endl;
cout<<setprecision(4)<<c<<endl;
cout<<setprecision(5)<<c<<endl;
getch( );
}

Tidak ada komentar:

Posting Komentar