1 / 9

CONTOH-CONTOH SOAL BESERTA PROGRAMNYA

CONTOH-CONTOH SOAL BESERTA PROGRAMNYA. Buat Pyramid Angka 2 baris, seperti gambar di bawah:. #include <iostream.h> #include <conio.h> int main() { clrscr(); int x, y, z, bil=5; for( x = 1; x <= bil; x++ ) {for( z = bil; z >= x; z-- ) cout << ' ';

palani
Download Presentation

CONTOH-CONTOH SOAL BESERTA PROGRAMNYA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CONTOH-CONTOH SOAL BESERTA PROGRAMNYA

  2. Buat Pyramid Angka 2 baris, seperti gambar di bawah: #include <iostream.h> #include <conio.h> int main() { clrscr(); int x, y, z, bil=5; for( x = 1; x <= bil; x++ ) {for( z = bil; z >= x; z-- ) cout << ' '; for( z = x; z < 2*x; z++ ) {y = z % 5; cout << y;} for( z = 2*(x-1); z >= x; z-- ) {y = z % 5; cout << y;} cout << endl; } getch(); }

  3. Buat program konversi Celcius ke Fahrenheit? #include <conio.h> #include <stdio.h> main(){ clrscr(); float celcius, fahrenheit; char lagi='Y'; printf(“konversi celcius ke fahrenheit \n"); do {printf("\nNilai celcius : "); scanf("%f", &celcius); fahrenheit=1.8*celcius+32; printf("Nilai Fahrenheit :%.2f\n", fahrenheit);

  4. printf("Coba lagi (Y/T) ? "); scanf("%s", &lagi); } while (lagi=='Y' || lagi=='y'); getch(); }

  5. Buat program menentukan bilangan prima dari n nilai sampai n nilai,ex : dari 5 sampai 10. #include <conio.h> #include <iostream.h> #include <math.h> void prima(); int a,b,c; main (){ clrscr (); cout<<"Masukkan nilai awal : "; cin>>a; cout<<"Masukkan nilai akhir: "; cin>>b; prima (); getch ();}

  6. void prima () { cout<<"Bilangan Prima antara "<<a<<"-"<<b<<": "<<endl; for (c=a;c<=b;c++) { if ((c==2)||(c==3)||(c==5)||(c==7)) {cout<<c<<" "; } else if ((c%2!=0)&&(c%3!=0)&&(c%5!=0)&&(c%7!=0)) {cout<<c<<" "; } } }

  7. Buat program menentukan bilangan terbesar dan terkecil dari jumlah data yang diinput? #include <conio.h> #include <stdio.h> main(){ clrscr(); int i, n, max, min, bil; printf (“Mencari bilangan max dan min \n"); printf("Banyak data : "); scanf("%d", &n); printf("Masukkan bilangan : "); scanf("%d", &bil); max=bil; min=bil;

  8. for (i=2; i<=n;i++) { printf("Masukkan bilangan : "); scanf("%d", &bil); if (bil>max) max=bil; if (bil<min) min=bil; } printf ("Data terbesar %d \n", max); printf ("Data terkecil %d \n", min); getch(); }

  9. Silahkan dimodifikasi sendiri menggunakan fungsi dengan parameter pointer Dan pelajari latihan2 yang pernah anda kerjakan sebagai tugas dan latihan di lab

More Related