C Program Compute Distance Covered By Car

By | June 17, 2019

This is a basic C Programming language program. It is a formula calculation example program in C language.

This program uses the following statements:

  1. First line starts with Pre processor directives
  2. Pre processor directives will include required header file/s.
  3. It uses scanf() function for input.
  4. We use printf() function for output
  5. This program uses assignment statement for formula calculation.
  6. At the end show result with printf() function.
  7. You can compile and run the program according to the facilities provided by your IDE.

/*
 C Program 
to calculate distance covered by car 
when time, velocity and acceleration
is given 
*/
#include<stdio.h>

int main()
{
   float s, vi, a, t;
   printf("Enter intial velocity of car =");
   scanf("%f", &vi);
   printf("Enter acceleration =");
   scanf("%f", &a);
   printf("Enter time =");
   scanf("%f", &t);
   s = vi * t + 1.0/2.0 *a * t * t;
   printf("Distance covered by car is=%f m", s);
   return 0;
}

C Program to calculate distance covered by car
when time, velocity and acceleration is given

C Program to calculate distance covered by car when time, velocity and acceleration is given

C Program Compute Distance Covered By Car
This c program calculates distance covered by car
when time, velocity and acceleration is given.

Write a C Program to calculate distance covered by car
when time, velocity and acceleration is given.

During the execution of this program, the user will input initial velocity in variable vi, acceleration in variable a. The program then computes the formula and assign resultant value to variable s.

C Program  to calculate distance covered by car  when time, velocity and acceleration is given

Here is the sample output of this C Program. This C program computes distance covered by a car when time, velocity and acceleration are given. It use the formula s = vit + 1/2 at

The program uses a simple assignment statement to compute the distance. The program displays the distance on screen using printf() function.

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *