Penggunaan Printf()

Listing Contoh-1. Simpan File Dengan Nama LAT01.CPP

#include
#include

void main()
{
int a = 7;
char b = 'G';

printf("%c Merupakan Abjad Yang ke - %d", b, a);
getch();
}


Output yang akan dihasilkan oleh program contoh 1 diatas adalah :





Gambar 1.1 Hasil Contoh 1



LATIHAN 2

//penggunaan manipulator setfill()



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

void main()
{
    int a;

   cout<<"Penggunaan Manipulator Setfill()"<<"\n\n";
   cout<<"---------------------------------"<<"\n";
   for(a=1;a<=15;a++)
   {
       cout<<setfill('-') ;
      cout<<setw(a)<<a<<endl;
   }
   cout<<"---------------------------------"<<"\n";
   getche();
}



Hasil Keluaran, gambar 1.2