A C program works as DISTANCE CONVERTER cms / kms / miles to metres – IGNOU MCA Assignment 2014 – 15

By | July 15, 2014

MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2014-15
Maximum Marks : 100
Weightage : 25%

 

Write an interactive program called “DISTANCE CONVERTER” that accepts the distance/length in centimetres / kilometres /miles and displays its equivalent in metres.

 

#include<stdio.h>
void main()
{
int NUM;
float DISTANCE,METERS;
clrscr();
printf(“SELECT MEASURING METRICS”);
printf(“\n 1. CENTIMETERS\n”);
printf(“\n 2. KILOMETERS\n”);
printf(“\n 3. MILES\n”);
printf(“ENTER CHOICE HERE :”);
scanf(“%d”,&NUM);
switch(NUM)
{
case 1 : printf(“\n SELETED CENTIMETERS TO METERS\n”);
break;
case 2 : printf(“\n SELETED KILOMETERS TO METERS\n”);
break;
case 3 : printf(“\n SELETED MILES TO METERS\n”);
break;
default : printf(“YOU HAVE ENTERED WRONG CHOICE !!!”);
goto QUIT;
}
printf(“ENTER WEIGHT HERE :”);
scanf(“%f”,&DISTANCE);
switch(NUM)
{
case 1 : METERS=DISTANCE/100;
printf(“\n %.2f CENTIMETERS IS %.2f METERS\n”,DISTANCE,METERS);
break;
case 2 : METERS=DISTANCE*1000;
printf(“\n %.4f KILOMETERS IS %.4f METERS\n”,DISTANCE,METERS);
break;
case 3 : METERS=(DISTANCE*1609344)/1000;
printf(“\n %.4f MILES IS %.4f METERS\n”,DISTANCE,METERS);
break;

}
QUIT:
getch();
}

Code:

[codesyntax lang=”c”]

#include<stdio.h>
void main()
{
int NUM;
float DISTANCE,METERS;
clrscr();
printf(“SELECT MEASURING METRICS”);
printf(“\n 1. CENTIMETERS\n”);
printf(“\n 2. KILOMETERS\n”);
printf(“\n 3. MILES\n”);
printf(“ENTER CHOICE HERE :”);
scanf(“%d”,&NUM);
switch(NUM)
{
case 1 : printf(“\n SELETED CENTIMETERS TO METERS\n”);
break;
case 2 : printf(“\n SELETED KILOMETERS TO METERS\n”);
break;
case 3 : printf(“\n SELETED MILES TO METERS\n”);
break;
default : printf(“YOU HAVE ENTERED WRONG CHOICE !!!”);
goto QUIT;
}
printf(“ENTER WEIGHT HERE :”);
scanf(“%f”,&DISTANCE);
switch(NUM)
{
case 1 : METERS=DISTANCE/100;
printf(“\n %.2f CENTIMETERS IS %.2f METERS\n”,DISTANCE,METERS);
break;
case 2 : METERS=DISTANCE*1000;
printf(“\n %.4f KILOMETERS IS %.4f METERS\n”,DISTANCE,METERS);
break;
case 3 : METERS=(DISTANCE*1609344)/1000;
printf(“\n %.4f MILES IS %.4f METERS\n”,DISTANCE,METERS);
break;

}
QUIT:
getch();
}

[/codesyntax]

Screen Shots:

C_program_Distance_Converter

C_program_Distance_Converter_Output

Leave a Reply