Sie sind auf Seite 1von 7

Application Programming and Computer Practice Reports

About
The Next Branching Technique

By:
Diniyatil Ulya 18063035

Supervisors:
Citra Dewi SP.d,M.Eng

Electrical Engineering and Education (S1)


Engineering Faculty
Padang State University
TH.2020-2021
A. Purpose
1. Understand the reading of data branched out in the programming language
2. Practicing branching commands in the programming language

B. The program determines prices based on program status.

#include <stdio.h>
#include <string.h>
#include <conio.h>
int main ()
{
char status [2],jabatan [2];
int harga;
printf ("masukkan status (1.mahasiswa/2.non mahasiswa):");
scanf ("%s",&status);
if (strcmp(status,"1")==0)
{
printf ("masukkan jabatan (1.panitia/2.non panitia):");
scanf ("%s",&jabatan);
if (strcmp(jabatan,"1")==0)
{

harga=80000;
printf ("\nharga:%d",harga);
}
else if (strcmp(jabatan,"2")==0)
{
harga=120000;
printf ("\nharga:%d",harga);
}
else
{
printf ("\ninput jabatan salah !!");

}
}
else if (strcmp (status,"2")==0)
{
printf ("masukkan jabatan (1.panitia/2.non panitia):");
scanf ("%s",&jabatan);
if (strcmp(jabatan,"1")==0)
{
harga=100000;
printf ("\nharga:%d",harga);
}
else if (strcmp (jabatan,"2")==0)
{
harga=150000;
printf ("\nharga : %d",harga);
}
else
{
printf ("\ninput jabatan salah !!");
}
}
else
{
printf ("input status salah !!");
}
return 0;
}

C. Grade information program using Case of.

#include <stdio.h>
#include <conio.h>
int main ()
{
int nilai ;
printf ("masukkan nilai 1-3 :");scanf ("%d,",&nilai);
switch (nilai)
{
case 1:
printf ("satu\n");
break;
case 2:
printf ("dua\n");
break;
case 3:
printf ("tiga\n");
break;
default:
printf ("bukan nilai 1,2 atau 3\n");
break;

}
return 0;
}

D. Bonus determination program for buyers based on total purchases entered.

#include <stdio.h>
#include <conio.h>
#include <string.h>
int main ()
{
int total1,total2;
float totdisc;
printf ("masukkan total pembelanjaan pembeli : Rp.");scanf
("%i",&total1,total2);
if (total1 >100000)
{
totdisc=total1*0.10;
total2=total1-totdisc;
printf ("\nselamat anda mendapatkan diskon sebesar Rp.%.of",totdisc);
printf
("\n=====================================================
==");
printf ("\njumlah pembayaran yang harus dibayar setelah dikurangi
Disc adalah Rp.%d",&total1,&total2);
printf("\n======================================================
===========================");
}
else if (total1 <100000& total2 >500000)
{
printf ("\nselamat anda mendapatkan piring cantik");
}
else if (total1 <500000&total2>10000)
{
printf ("\nselamat anda mendapatkan gelas cantik");
}
else if (total2<10000)
{
printf ("\nmaaf anda belum mendapatkan bonus");
}
return 0;

}
E. Calculator program that accepts entering two numbers, then accepts entering menu
options in the form of addition, subtraction, and multiplication.
 
#include <stdio.h>
#include <conio.h>
 int main()
{
int pil;
float a,b,c;
printf("===== Program Kalkulator Sederhana =====\n\n");
printf("Masukan bilangan pertama : ");scanf("%f",&a);
printf("\nMasukan bilangan kedua : ");scanf("%f",&b);
printf("\n\n<<< Menu Pilihan >>>\n\n");
printf("1. Penjumlahan \n");
printf("2. Pengurangan \n");
printf("3. Perkalian \n");
printf("4. Pembagian \n\n");
printf("Operasi apa yang anda inginkan ( 1-4 )? : \n\n");scanf("%d",&pil);
printf("==== hasil ====\n\n");
switch(pil)
 {
case 1: c = a + b; 
printf(" %g + %g = %g",a,b,c);
break;
case 2: c = a - b;
 printf(" %g - %g = %g",a,b,c);
 break;
case 3: c = a * b;
 printf(" %g * %g = %g",a,b,c);
 break;
case 4: c = a / b;
 printf(" %g : %g = %g",a,b,c);
 break;
default:
 printf("\n >> Operasi yang anda masukan tidak ada pada menu !");
}
return 0;
}
F. Conclusion.
The switch case statement is an alternative to the if statement for problems with
multiple choices, the switch case provides more clarity than if.switch case is used to
replace the if-else-if structure where conditions refer to the same variable.

Das könnte Ihnen auch gefallen