Commit bd2c0ef2 by mahunt

all

parent 14acc335
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void tableMaker(int step, int x, float y);
// This function is used to make the majority of the table
void tableMaker(int counter, int x, float y)
{
printf("nr = %d x = %d y = %lf\n", counter, x, y);
}
int main()
{
// Variables used.
// They are preset for the while loop to prevent incorrect values
int i;
int x = 1;
float end = 0;
float step = -1;
int counter = 1;
// The while loop is used to prevent the user from entering incorrect values
while(end < x || step <= 0)
{
printf("Please enter a starting value: ");
scanf("%d", &x);
printf("Please enter an ending value: ");
scanf("%f", &end);
printf("Please enter step coefficient: ");
scanf("%f", &step);
}
// To change step to an int value for results[]
int cast = step;
int cast2 = end;
float results[(cast2/cast)+1]; // Array for storing the results
// This loop is for calling the tableMaker function to make the table
for(i = x; i <= end; i+=step) // "i" is equal to "x" and added to with "step" while <= "end"
{
// Checks if it is undefined
if(i == 0 || i == 360 || i == 180)// If yes
{
printf("nr = %d x = %d missing\n", counter, i);
}
else// If no
{
results[counter-1] =((exp(sin(i))) + log(atan(i)))/sin(i);
tableMaker(counter, i, results[counter-1]);
counter++;
}
}
return 0;
// End
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment