Computer Science, asked by nani234, 1 year ago

Write a c program to find speed of an object

Answers

Answered by singhmahesh140
2
You're using integers (integer arithmetic) instead of floats.

An integer can be four bytes, but does not contain any decimals (0, 150035, but it can't be 3.1251). Floats are four bytes as well (most of the time), and do contain decimals (3.14), however, the overall range of floats is lower and harder to predict.

You're also using chars (1 byte). 1 byte = 8 bits so their minimum is -128 and there maximum is 127.

Answered by Soñador
0

Answer:

#include<constream.h>

void main()

{

clrscr();

float speed,distance,time;

cout<<"\n Enter distance in KM :";

cin>>distance;

cout<<"\n Enter time in minutes :";

cin>>time;

speed=distance/time;

cout<<"\n Speed ="<<speed;

getch();

}

Explanation:

Since, speed=distance/time

We used the same formula to find speed of a given object.

Make sure that the input is done as per the given unit.

Similar questions