C program to calculate velocity

Write a program in C to enter time and distance so its give velocity.


Example: 
Input distance: 12
Input time: 6 
Output: veocity = 2 

Required knowledge:

Fundamentals of C, Data types, Taking user input in C 

Program:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**************************************
 * C program to calculate velocity. *
 **************************************/
#include <stdio.h>
void main()
{
    int d,t,v;
     
    /*
     * get time and distance from user
     */
    printf("Enter distance : \n");
    scanf("%d", &d);
    printf("Enter time: \n");
    scanf("%d", &t);
     
    /* velocity calculation */
    v = d / t;
     
    /* Print velocity */
    printf("velocity = %d",v);
     
}
Outpu


















Enjoy it.............

Comments

Popular posts from this blog

C program to find square root of a number

C program to find maximum between two numbers