Latihan 4

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Latihan 4 as PDF for free.

More details

  • Words: 765
  • Pages: 12
#include <stdio.h> void main() { char kod; printf("masukkan markah grade\n"); scanf("%s",&grade); switch (grade) { case 'A': printf("jumlah markah anda ialah 75-100"); break; case 'B': printf("jumlah markah anda ialah 60-74"); break; case 'C': printf("jumlah markah anda ialah 47-59"); break; case 'D': printf("jumlah markah anda ialah 40-46"); break; case 'E': printf("jumlah markah anda ialah 0-39"); break; case 'F': printf("jumlah markah anda ialah 0-39"); break; default: prihtf(“sila masukkan markah yang betul”); } }

#include <stdio.h> void main() { char kod; printf("***SELAMAT DATANG KE KEDAI INI***\n"); printf("masukkan kod makanan\n"); scanf("%s",&kod); printf("A-nasiayam\n"); printf("B-nasikerabu\n"); printf("C-nasilemak\n"); printf("D-apa-apaair\n"); switch(kod) { case 'A':printf("nasiayam\n"); break; case 'B':printf("nasikerabu\n"); break; case 'C':printf("nasilemak\n"); break; case 'D':printf("apa-apaair\n"); break; default: printf("pilih menu anda\n"); } printf("***TERIMA KASIH...DATANG LAGI***/n"); }

#include <stdio.h> void main() { int kuantiti; char kod; float jumlah,harga; printf("masukkan kuantiti\n"); scanf("%d",&kuantiti); printf("masukkan kod\n"); scanf("%s",&kod); switch (kod) { case 'A': printf("pen\n"); harga=2.50; break; case 'B': printf("pembaris\n"); harga=2.00; break; case 'C': printf("pemadam\n"); harga=0.50; break; case 'D': printf("liquid paper\n"); harga=5.00; break; default: harga=0.00; } printf("jumlah=%f\n",kuantiti*harga); }

#include <stdio.h> void main() { char grade; printf("masukkan markah grade\n"); scanf("%s",&grade); switch (grade) { case 'A': printf("jumlah markah anda ialah 75-100"); break; case 'B': printf("jumlah markah anda ialah 60-74"); break; case 'C': printf("jumlah markah anda ialah 47-59"); break; case 'D': printf("jumlah markah anda ialah 40-46"); break; case 'E': printf("jumlah markah anda ialah 0-39"); break; case 'F': printf("jumlah markah anda ialah 0-39"); break; default: printf("sila masukkan markah yang betul"); } }

/*A program that calculate area of the room*/ #include<stdio.h> void main( ) { int width,length,area; printf("Enter Width:"); scanf("%d",&width); printf("EnterLength:"); scanf("%d",&length); area=width*length; printf("Width=%d\n",width); printf("Length=%d\n",length); printf("area=%d\n",area); }

#include<stdio.h> void main( ) { int width,length,perimeter; printf("Enter Width:"); scanf("%d",&width); printf("EnterLength:"); scanf("%d",&length); perimeter=width*length; printf("Width=%d\n",width); printf("Length=%d\n",length); printf("perimeter=%d\n",perimeter); }

#include<stdio.h> void main () { char nama [30],nopend[30],kos; int sem; printf(“masukkan nama\n”); scanf(“%s’,&nama); printf(“masukkan no pendaftaran\n”); scanf(“%s”,&nopend); printf(“masukkan kos\n”); scanf(“%s”,&kos); printf(“masukkan semester terkini\n”); scanf(%d”,&sem); printf(“nama=%s\n”,nama); printf(“no pendaftaran=%s\n”,nopend); printf(“kos=%s\n”,kos); printf(“semester=%d\n”,sem); }

#include <stdio.h> void main () { char code; printf("senarai kod makanan\n"); printf("A-nasilemak\n"); printf("B-nasikelabu\n"); printf("C-nasidagang\n"); printf("D-nasikuning\n"); printf("sila masukkan kod makanan pilihan anda\n"); scanf("%c",&code); if(code=='A') printf("nasilemak"); else if(code=='B') printf("nasikelabu"); else if(code=='C') printf("nasidagang"); else if(code=='D') printf("nasikuning"); else printf("sila masukkan kod yang betul"); } #include <stdio.h> void main() { int nombor=1; char nomborpelajar[20],namapelajar[30],kodsubjek[5],namasubjek[20]; while(nombor<=10) { printf("masukkan nomborpelajar %d\n",nombor); scanf("%s",nomborpelajar); printf("masukkan namapelajar\n"); scanf("%s",namapelajar); printf("masukkan kodsubjek\n"); scanf("%s",kodsubjek); printf("masukkan namasubjek\n"); scanf("%s",namasubjek); nombor ++; } printf("nomborpelajar=%s",nomborpelajar); printf("namapelajar=%s",namapelajar); printf("kodsubjek=%s",kodsubjek); printf("namasubjek=%s",namasubjek); }

#include <stdio.h> void main () { char code; printf (masukkan kod lesen\n); scanf (“%s”, code) switch (code) { case “B” : printf (“motocycle”); break; case “D” : printf (“cars”); break; case “E” : printf (“lorry”); break; default : printf (kod salah”); } }

Tukar pada “if” if (code== ‘B’) printf (“motorcycle”); else if (code== ‘D’) printf (“cars”); else if (code== ‘E’) printf (“lorry”); else printf (“kod salah”); # include <stdio.h> void main () { float berat; printf (“masukkan berat anda\n”); scanf (“%f”,&berat); if (berat>=50) printf (“anda gemuk”); else printf (“sederhana”); }

# include <stdio.h> void main () { float tinggi; printf (“masukkan ketinggian\n”); scanf (“%f”,&tinggi”); if(berat>=160) printf(“tinggi ideal”); else printf (“biasa aja”); } # include <stdio.h> void main () { Int no1,no2,hasil tambah,hasil darab,hasil tolak,hasil bahagi; char simbol; printf (“sila masukkan nombor pertama\n”); scanf (“%d”,&no1); printf (“sila masukkan nombor kedua\n”); scanf (“%d”,&no2); printf (“sila masukkan symbol\n”); scanf (“%s”,&symbol); switch (simbol) { case '+’ : hasiltambah=no1+no2; printf (hasil tambah = %d”,hasiltambah); break; case '-’ : hasiltolak=no2; printf (hasil tolak = %d”,hasiltolak); break; case '*’ : hasildarab=no2; printf (hasil darab = %d”,hasildarab); break; case '/’ : hasilbahagi=no1+no2; printf (hasil bahagi= %d”,hasilbahagi); break; default : printf (“sila masukkan simbol yang betul”); } }

Isipadu kuboid # include <stdio.h> void main () { int isipadu,panjang,lebar,tinggi; printf (“masukkan panjang\n”); scanf (“%d”,&panjang”); printf (“masukkan lebar\n”); scanf (“%d”,&lebar”); printf (“masukkan tinggi\n”); scanf (“%d”,&tinggi”); isipadu=panjang*lebar*tinggi; printf(“isipadu=%d”,isipadu); }

Jejari # include <stdio.h> void main () { int isipadu,jejari; printf (“masukkan jejari\n”); scanf (“%d”,&jejari); isipadu silinder = 4/3*3.142*jejari*jejari*jejari; printf (“isipadu = %d”,isipadu); }

# include <stdio.h> void main () { Int jumlahhelaian; float hargasehelai = 0.30,jumlahharga; printf(“masukkan jumlah helaian mukasurat\n”); scanf (“%d”,&jumlahhelaian); jumlahharga=jumlahhelaian*hargasehelai; printf (“jumlahharga%f”,jumlahharga); } # include <stdio.h> void main () { char simbol; printf (“masukkan symbol”); scanf (“%c”,&simbol); switch (simbol) { case ‘+’ : printf (“tambah”); break; case ‘-’ : printf (“tambah”); break; case ‘*’ : printf (“tambah”); break; case ‘/’ : printf (“tambah”); break; default : printf (“masukkan symbol yang betul”); } }

# include <stdio.h> void main () { int no1,no2,jumlah; printf (masukkan nombor1\n”); scanf (“%d”,&no1); printf (masukkan nombor2\n”); scanf (“%d”,&no2); jumlah=no1+no2; printf (“SUM=%d”,jumlah”); }

# include <stdio.h> void main () { float jumlah,hargakilo=1.5; int kuantiti; printf (‘masukkan kuantiti\n”); scanf(“%d”,&kuantiti”); jumlah=kuantiti*hargakilo; printf(“jumlah harga epal ialah = %f”,jumlah”); }

# include <stdio.h> void main () { float hargaasal,diskaun,hargabaru; printf (“masukkan hargaasal”); scanf (“%f”,&hargaasal”); diskaun=0.25*hargaasal; hargabaru=hargaasal-diskaun; printf(“hargaasal=%f”,hargaasal); printf(“diskaun=%f”,diskaun); printf(“hargabaru=%f”,hargabaru); }

Related Documents

Latihan 4
October 2019 17
Latihan 4
October 2019 13
Latihan 4.docx
December 2019 18
Fisio Latihan 4.docx
May 2020 25
Latihan Psikotes 4
October 2019 18