I.              Program Sederhana-1: Menampilkan ‘Hello, World!’ pada layar   
Langkah-langkah membuat template program sederhana:
1.    Jalankan software Microsoft Visual C++ 6.0 dari Microsoft Visual Studio 6.0 (jika perlu mintalah bantuan asisten)
2.    Pilih menu File -> New
3.    Pada dialog box pilih tabProjects, selanjutnya:
- Pilih/klik Win 32 Console Application
- Tulis nama project, misalkan ProgramPertamaku pada isian Project_name:
- Tentukan direktori tempat project ini berada pada Location: (kemungkinan diisi dengan direktori home anda)
- Klik OK
4.    Akan muncul dialog box Win 32 Console Application:
- Pilih radio button A “Hello, World!” application
- Klik Finish
- Klik OK
5.    Pada window kecil (biasanya di sebelah kiri):
- Klik tab FileView
- Klik tanda + pada ProgramPertamaku files
- Klik tanda + pada Source files
- Double Klik pada ProgramPertamaku.cpp, akan muncul teks program :
// ProgramPertamaku.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
      printf("Hello World!\n");
      return 0;
}
6.    Pilih menu Build -> Build ProgramPertamaku.exe atau tekan F7 pada keyboard
7.    Pilih icon/gambar tanda seru (!), akan muncul window console seperti berikut:

II. Program Sederhana-2: Membaca dua buah bilangan bulat dan menampilkan hasil penjumlahannya
Petunjuk:
1.    Gunakan langkah-langkah pembuatan templateprogram seperti di atas sampai langkah ke-5 , tetapi gunakan Project_nameyang berbeda,misalnya ProgramKeduaku
2.    Gantilah blok program fungsi maindengan yang berikut:
   int integer1; /* first number to be input by user  */
   int integer2; /* second number to be input by user */
   int sum;      /* variable in which sum will be stored */ 
   printf( "Enter first integer\n" ); /* prompt */
   scanf( "%d", &integer1 );          /* read an integer */
   printf( "Enter second integer\n" ); /* prompt */
   scanf( "%d", &integer2 );           /* read an integer */
   sum = integer1 + integer2; /* assign total to sum */
   printf( "Sum is %d\n", sum ); /* print sum */
   return 0; /* indicate that program ended successfully */
3.    Lakukan langkah-6 dan 7 templateseperti program I
III. Program Sederhana-3: Mencoba operator persamaan dan operator relasi
Petunjuk:
1.    Gunakan langkah-langkah program II , tetapi gunakan Project_name yang berbeda,misalnya ProgramKetigaku
2.    Gantilah blok program fungsi maindengan yang berikut:
   int num1; /* first number to be read from user  */
   int num2; /* second number to be read from user */
   printf( "Enter two integers, and I will tell you\n" );
   printf( "the relationships they satisfy: " );
   scanf( "%d%d", &num1, &num2 ); /* read two integers */
   if ( num1 == num2 ) { 
      printf( "%d is equal to %d\n", num1, num2 );
   } /* end if */
   if ( num1 != num2 ) {
      printf( "%d is not equal to %d\n", num1, num2 );
   } /* end if */
   if ( num1 < num2 ) { 
      printf( "%d is less than %d\n", num1, num2 );
   } /* end if */
   if ( num1 > num2 ) { 
      printf( "%d is greater than %d\n", num1, num2 );
   } /* end if */
   if ( num1 <= num2 ) { 
      printf( "%d is less than or equal to %d\n", num1, num2 );
   } /* end if */
   if ( num1 >= num2 ) {
      printf( "%d is greater than or equal to %d\n", num1, num2 );
   } /* end if */
   return 0; /* indicate that program ended successfully */
 selamat mencobah yach teman-teman cyber-software




0 komentar:
Posting Komentar