Answer to Question #334019 in C for Anne

Question #334019

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
Expert's answer
2022-04-26T14:49:12-0400

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;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS