Sahyadri College of Engineering & Management, Mangaluru Mini-Project Report
Sahyadri College of Engineering & Management, Mangaluru Mini-Project Report
Course Title : C and C++ Industry Connect Program Date: 10/10/2018 Sem / Section:3/A
Faculty: Mr. Vijay C P & Mr. Srinath K S
Student Name: Likhith R USN:4SF17CS078
Description:
Imagine we have to travel a certain distance and there are different modes of transport. And if you chose any
mode the application will give you the time taken by that type of transport to cover the distance.
Input Format:
Input: 350
3
Expected Output:
Source Code:
//Authors: Likhith R
//Date: 26/10/2018
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef int I;
typedef char C;
typedef float F;
I mode;
I distance;
F time(F speed) //function calculating time
{
F time_required;
time_required=distance/speed; //calculates time
return time_required; //returns time to main
}
void main()
{
F tim;
C mod[7];
printf("\n\t\t\tProgram to Calculate time to travel based on distance and vehicle\n\n");
printf("\tEnter the Distance in KM\n\t");
scanf("%d",&distance); //takes distance as input
printf("\tEnter the mode of transportation as below\n");
printf("\t1.Bike\n\t2.Bus\n\t3.Flight\n\t4.Train\n\t5.Ship\n\t");
scanf("%d",&mode); //entering which mode
switch(mode) //to calculate time of each mode
{
case 1: tim=time(60);
break;
case 2: tim=time(80);
break;
case 3: tim=time(814);
break;
case 4: tim=time(180);
break;
case 5: tim=time(40);
break;
default:printf("Mode of Transport not available\n");
exit(0);
}
switch(mode) //to save the mode of transportation in a variable
{
case 1: strcpy(mod,"Bike");
break;
case 2: strcpy(mod,"Bus");
break;
case 3: strcpy(mod,"Flight");
break;
case 4: strcpy(mod,"Train");
break;
case 5: strcpy(mod,"Ship");
break;
}
printf("\n\tThe time taken by %s is %f hours",mod,tim); //displaying result
}
Output: