Computer Science, asked by alexadsouza64, 10 months ago

Write a c program to calculate velocity of a car when distance and time are given by the user.

Answers

Answered by codiepienagoya
0

C program to calculate velocity

output:

Enter time: 5.6

Enter distance: 50

velocity: 8.928572

Explanation:

Program to calculate velocity as follows:

Program:

#include <stdio.h> //defining header file

int main() //defining main method

{

   float t,distance,velocity; //defining float variable

   printf("Enter time: "); //message

   scanf("%f",&t); //input value by user

   printf("Enter distance: "); //message

   scanf("%f",&distance); //input value by user

   velocity=distance/t; //use formula to calculate velocity

   printf("velocity: %f",velocity); //print calculated value

   return 0;

}

Description of the above code as follows:

  • In the above C language code, the header file is include, then the main method is declared, inside this method all the calculation is done.
  • In the main method the three float variable "t, distance, and velocity" is defined, in which variable "t and distance" is used to take value by the user.
  • In the next step, the velocity variable is declared, that calculate velocity by applying the given formula, and uses the print function to print velocity value.    

Learn more:

  • Program in C: https://brainly.in/question/14470592
Similar questions