1. Write a C program that finds the smallest among the five integers inputted by the user.
2. The following program determines the proper fare of a passenger with the following data:
a.) Senior citizens and PWD enjoys 25%
b.) Students enjoys 15%
c.) Regular passengers have to pay the regular fare
1)
#include <stdio.h>
#define ARR_SIZE 5
int main()
{
int arr[ARR_SIZE];
int minimal=0;
printf("Enter %i numbers\n",ARR_SIZE);
for(int i=0;i<ARR_SIZE;i++)
{
scanf("%i",&arr[i]);;
}
minimal=arr[0];
for (int i=1;i<ARR_SIZE;i++)
{
if(arr[i]<minimal) minimal=arr[i];
}
printf("smallest is %i\n",minimal);
return 0;
}
2)
#include <stdio.h>
void fareDiscount(int fare,int procent)
{
printf("Fare is %i\n",fare-(fare/100*procent));
}
int main()
{
int fare = 100;
int mode = 0;
printf("1<-Senior citizens and PWD\n2<-Students\n3<-Regular passenger\n");
scanf("%i",&mode);
switch(mode)
{
case 1:
fareDiscount(fare,25);
break;
case 2:
fareDiscount(fare,15);
break;
case 3:
fareDiscount(fare,0);
break;
}
}
Comments
Leave a comment