0% found this document useful (0 votes)
21 views3 pages

Lab03.c: Defines The Entry Point For The Console Application

This document contains C code for a program that calculates the range of a projectile. It defines functions to print the name of the programmer, get velocity and angle values from the user, convert the angle to radians, calculate the range using the velocity and angle, and pause the program before exiting. The main function calls the other functions to run the program and display the results.

Uploaded by

JabneelCruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

Lab03.c: Defines The Entry Point For The Console Application

This document contains C code for a program that calculates the range of a projectile. It defines functions to print the name of the programmer, get velocity and angle values from the user, convert the angle to radians, calculate the range using the velocity and angle, and pause the program before exiting. The main function calls the other functions to run the program and display the results.

Uploaded by

JabneelCruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

// Lab03.c : Defines the entry point for the console application.

#include "myfunctions.h"
int main(void)
{
PrintName();
PrintRange();
Pause();
}

//myfunctions.c
#include <stdio.h>
#include <math.h>
#include "myfunctions.h"

void PrintName()
{
printf("\n Hello my name is:\t Jabneel Cruz \n");
printf("\n My student number is: N01035243\n");
}
void PrintRange(void)
{
double Vms = 0.0;
double AngleDegrees = 0.0;
double AngleRads = 0.0;

printf("\nEnter the Projectile Velocity(m/s): ");

scanf(" %lf", &Vms);


printf("Enter the Projectile Angle(degrees): ");
scanf(" %lf", &AngleDegrees);

AngleRads = ConvertToRadians(AngleDegrees);

iprintf("\nYour projectile would travel%10.1lf metres.", Range(Vms,AngleRads));

double ConvertToRadians(double AngleDegrees)


{
return AngleDegrees * PI / 180;
}

double Range(double Vms, double AngleRads)


{
return (Vms * Vms * sin(2* AngleRads)) / GRAV;
}

void Pause()
{
while(getchar()!= '\n');
printf("\n\nPress any key to continue...");
getchar();

}
//makefile
lab03: lab03.o myfunctions.o
gcc -g -o lab03 lab03.o myfunctions.o -lm
lab03.o: lab03.c myfunctions.h
gcc -g -c lab03.c
myfunctions.o: myfunctions.c myfunctions.h
gcc -g -c myfunctions.c
//myfunctions.h
#ifndef MYFUNCTIONS_H
#define MYFUNCTIONS_H
#define PI 3.14159
#define GRAV 9.81
void PrintRange(void);
double ConvertToRadians(double AngleDegrees);
double Range(double Vms, double AngleRads);
#endif

You might also like