Program to input distance in km and calculate into meter.
About this program
In this program we input a value in km and Convert into meter.
#include<stdio.h>
#include<conio.h>
void main()
{
long int km,m;
clrscr();
printf("Enter distance in km=");
scanf("%d",&km);
m=1000*km;
printf("Distance in m=%d",m);
getch();
}
OUTPUT
Explanation : 1st step of program we use stdio.h header file because we'll use printf(); and scanf(); in this program and conio.h header file use because we'll use clrscr(); and getch(); . After this we use void main for open brace { . Main function does not return a value so we use void. This is almost same in many programs.
Then we declare variable as km and define its type as long int. Then use clrscr(); , printf and print a message for user after it we'll use scanf(); to input a number by user. We know 1km=1000m ,so we write logic and print their value by printf. At last we use getch(); for see output screen while we input a key.
Any problems please comment and never forget to Subscribe for recently updates.
Related Examples
1.Write a program to input two number and print their sum .
2.Write a program to input two number and print their subtraction.
In this program we input a value in km and Convert into meter.
#include<stdio.h>
#include<conio.h>
void main()
{
long int km,m;
clrscr();
printf("Enter distance in km=");
scanf("%d",&km);
m=1000*km;
printf("Distance in m=%d",m);
getch();
}
OUTPUT
Explanation : 1st step of program we use stdio.h header file because we'll use printf(); and scanf(); in this program and conio.h header file use because we'll use clrscr(); and getch(); . After this we use void main for open brace { . Main function does not return a value so we use void. This is almost same in many programs.
Then we declare variable as km and define its type as long int. Then use clrscr(); , printf and print a message for user after it we'll use scanf(); to input a number by user. We know 1km=1000m ,so we write logic and print their value by printf. At last we use getch(); for see output screen while we input a key.
Any problems please comment and never forget to Subscribe for recently updates.
Related Examples
1.Write a program to input two number and print their sum .
2.Write a program to input two number and print their subtraction.
Comments
Post a Comment