Practical - 4 - Write a program to read the distance in kilometre and convert it into meters and centimetres.

Practical - 4


Aim: Write a program to read the distance in kilometre and convert it into meters and centimetres.

Program:

#include <stdio.h>

#include <conio.h>

 

void main()

{

    clrscr();

    long int km, m, cm;

 

    printf("Enter the distance in kilometre = ");

    scanf("%ld", &km);

 

    m = km * 1000;

    cm = km * 100000;

 

    printf("\nIn meter = %ld", m);

    printf("\nIn centimetre = %ld", cm);

 

    getch();

}

 

Output:

Enter the distance in kilometre = 6

 

In meter = 6000

In centimetre = 600000

 

Algorithm:

 

Step-1: START

Step-2: Declare km, m, cm.

Step-3: Enter the value of km.

Step-4: m = km * 1000.

Step-5: cm = km * 100000.

Step-6: Display m and cm.

Step-7: STOP.

 

Flowchart:



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.