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 CProgram:
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); } |
Enjoy it.............
Comments
Post a Comment
Dears! Yours Comment approved in 24 hours also your answer in 24 hours.......