Home Basic Loop Array string Function Pointer Contact STUDY

# AHF    C    PROGRAM    SOLVING

### Function_ a equation for finding velocity and distance

```
// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h>
#include<math.h>
#define pf printf

//function declaration
float dis(float v, float a, float t);

float vel(float v, float a, float t);

void main()
{
float x,y,z;
float distance,velocity;

pf("\nEnter the velocity: ");
scanf("%f",&x);

pf("\nEnter the acceleration: ");
scanf("%f",&y);

pf("\nEnter the time: ");
scanf("%f",&z);

//call first function
distance=dis(x,y,z);

//call second function
velocity=vel(x,y,z);

pf("\nThe distance is: %.2f",distance);

pf("\nThe velocity is: %.2f",velocity);

return 0;
}

//definition of first function
float dis(float v, float a, float t)    //function header

//body of the first function
{
float m;

m=v+(a*t);  //finding velocity

return m;
}

//definition of the second function
float vel(float v, float a, float t)    //function header

//body of the second function
{
float n;

n=v*t+(.5*a*t*t);   //finding distance

return n;
}

```
OUTPUT: