int main (int argc, char * argv [])
{
int i = 4;
int j = 5;
int k;
k = maximum (i, j); / * calling function maximum or largest function * /
printf ("% d largest of% d and% d \ n", k, i, j);
printf ("% d largest of% d and% d \ n", maximum (3.5), 3, 5);
return 0;
}
int maximum (int a, int b)
/ * largest integer return * /
{
if (a> b)
return a;
return b;
}
2.1.2. Practice 2 (Student Data)
· Program Listings
#include <stdio.h>
#include <conio.h>
#include <stdio.h>
// Declaration of new data type of Student struct
typedef struct Student {
char NIM [9];
char name [30];
float ipk;
};
void main () {
// Create variable mhs of type Student data
Student mhs;
clrscr ();
printf ("NIM ="); scanf ("% s", mhs.NIM);
printf ("Name ="); scanf ("% s", mhs.name);
printf ("IPK ="); scanf ("% f", & mhs.ipk);
printf ("Your data: \ n");
printf ("NIM:% s \ n", mhs.NIM);
printf ("Name:% s \ n", mhs.name);
printf ("GPA:% f \ n", mhs.ipk);
getch ();
}
2.1.3. Practice 3 (Age)
· Program Listings
#include <stdio.h>
#include <conio.h>
typedef int numbers;
typedef fractional float;
typedef char letters;
void main () {
clrscr ();
age number;
broken fragments;
letter h;
letter name [10];
printf ("Enter your age:");
scanf ("% d", & age);
printf ("your age is% d", age);
printf ("\ nnumber fractions:");
scanf ("% f", & broke);
printf ("fraction number f", broke);
printf ("enter letter:"); h = getche ();
printf ("\ nhuruf you% c", h);
printf ("\ nname in:");
scanf ("% s", name);
printf ("Your name% s", name);
getch ();
}
2.1.4. Practice 4 (Login ID)
· Program Listings
#include <stdio.h>
#include <conio.h>
typedef struct Date {
int dd;
int mm;
int yyyy;
};
typedef struct Time {
int h;
int m;
int s;
};
typedef struct Login {
int ID;
Date tglLogin;
Time timeLogin;
};
int main () {
Login user1;
printf ("USER 1 \ n");
printf ("ID:"); scanf ("% d", & user1.ID);
printf ("Date of Login \ n");
printf ("Day:"); scanf ("% d", & user1.tglLogin.dd);
printf ("Month:"); scanf ("% d", & user1.tglLogin.mm);
printf ("Year:"); scanf ("% d", & user1.tglLogin.yyyy);
printf ("Login Time \ n");
printf ("Clock:"); scanf ("% d", & user1.waktuLogin.h);
printf ("Minutes:"); scanf ("% d", & user1.waktuLogin.s);
printf ("Seconds:"); scanf ("% d", & user1.waktuLogin.s);
printf ("Thank you \ n");
printf ("Your data: \ n");
printf ("ID:% d \ n", user1.ID);
printf ("Date:% d -% d -% d \ n", user1.tglLogin.dd, user1.tglLogin.mm, user1.tglLogin.yyyy);
printf ("ID:% d:% d:% d \ n", user1.waktuLogin.h, user1.waktuLogin.m, user1.waktuLogin.s)
getch ();
}
2.2.Results / Outputs
2.2.1. Practice 1 (Funtion Largest)
(i) This is the view of the program created using the largest function. This program is not an input program, so this program will directly display output in accordance with the coding program that we make. See (Figure 2.2.1.1 Display results from Maximum program)
