You are on page 1of 1

ASSIGNMENT 1 (C01)

NAME : PHIPHOP A/L BOON COM


MATRIC NO : 231110992
PROGRAMME : UR6521001 (Y1G1)
COURSE : MMJ12503 COMPUTER PROGRAMMING
DATE : 24 OCTOBER 2023

/*Assignment 1 (C01)*/
#include <stdio.h> /*Preprosessor directives*/
#include <math.h> /*Preprosessor directives*/

#define g 9.81 /*Declare constant*/

int main() /*Main function*/


{
float u, v, w, x, mass; /*Variables declaration*/

printf("Enter the mass of the object(kg):"); /*Formatted output*/


scanf("%f", &mass); /*input mass value*/
printf("Enter the initial velocity(m/s):"); /*Formatted output*/
scanf("%f", &v); /*input initial velocity value*/
printf("Enter the time in motion(s):"); /*Formatted output*/
scanf("%f", &x); /*input time value*/

u = v + (g*x); /*Formula for final velocity*/


w = v*x + (0.5*g*(x*x)); /*Formula for distance traveled*/

printf("\nFinal velocity (Vf): %f\n", u); /*Output final answer*/


printf("Distance traveled (s): %f\n", w); /*Output final answer*/

return 0; /*End*/
}

You might also like