I am only a very beginner and was wondering if anyone can give me some help in determining how to fix the error messages i keep getting when i try to compile. I have been pulling my hair out for 3 days. Any help is much appreciated! attached is the code i have come up with so far and the errors down at the bottom as well as what its suppose to do.
#include <stdio.h>
void getInput();
void calculate(int num1, int num2, int num3, float num4);
void printTable(int num1, int num2, int num3, float num4,int calc1, int calc2, int calc3, int calc4, double calc5, double calc6, float calc7, float calc8);
int main (void)
{
int num1, num2, num3, float num4, int calc1, int calc2, int calc3, int calc4, double calc5, double calc6, float calc7, float calc8);
getInput;
calculate;
printTable;
return 0;
}
void getInput ()
{
int num1, num2, num3;
float num4;
printf("Enter three integers and a floating point number then press enter: ");
scanf("%d %d %d %d" , &num1, &num2, &num3, &num4);
return ;
}
void calculate (int num1, int num2, int num3, float num4)
{
int calc1, calc2, calc3, calc4;
double calc5;
double calc6;
float calc7, calc8;
calc1 = num1+num3;
calc2 = num1*num2;
if (num4 < 0)
{
calc3 = ((num4/100) %10) * -1;
}
else
{
calc3 = (num4/100) %10;
}
calc4 = num2/num3;
calc5 = num3 * num4;
calc6 = num3/num1;
calc7 = num1 + num2 + num3 + num4;
calc8 = calc7 / 4;
}
void printTable (int num1, int num2, int num3, float num4, int calc1, int calc2, int cal3, int calc4, double calc5, double calc6, float calc7, float calc8);
{
printf("\n Input 1 (int) :-28%14.2d\n", num1 );
printf("\n Input 2 (int) :-28%14.2d\n", num2 );
printf("\n Input 3 (int) :-28%14.2d\n", num3 );
printf("\n Input 4 (float) :-28%14.2f\n", num4 );
printf("\n Input 1 + Input 3 (int) :-28%14.2d\n", calc1 );
printf("\n Input 1 * Input 2 (int) :-28%14.2d\n", calc2 );
printf("\n Hundreds Digit of Input 4 :-28%14.2d\n", calc3 );
if (num3 !=0)
printf("%-28s%14d\n","input 2 / Input 3 (int)", calc4);
else
printf("%-28s%14s\n","input 2 / input 3 (int)", "DIV/0");
printf("\n Input 2 / Input 3 (int) :-28%14.2f\n", calc4 );
printf("\n Input 3 * Input 4 (double) :-28%14.2f\n", calc5 );
if (num3 !=0)
printf("%-28s%14d\n","input 3 / Input 1 (int)", calc6);
else
printf("%-28s%14s\n","input 3 / input 1 (int)", "DIV/0");
printf("\n Input 3 / Input 1 (double) :-28%14.2f\n", calc6 );
printf("\n Sum of the input (float) :-28%14.2f\n", calc7 );
printf("\n Average of the input (float) :-28%14.2f\n", calc8 );
return;
}
ERROR MESSAGES
In function `main':
10 syntax error before "float"
40 invalid operands to binary %
44 invalid operands to binary %
At top level:
55 syntax error before '{' token
55 syntax error before '{' token
58 conflicting types for 'printf'
58 a parameter list with an ellipsis can't match an empty parameter name list declaration
58 conflicting types for 'printf'
58 THROUGH 76 a parameter list with an ellipsis can't match an empty parameter name list declaration.
WHAT IT'S SUPPOSE TO DO
*not allowed to use global variables except for debug flag.
*Prompts the user for three integers and one floating point number.
*Reads the three integers and one floating point number from the user (you can assume that the users enters valid numbers, so you don't need to do error checking.)
*Performs the following calculations
*Calculates the integer sum of the first and third numbers
*Multiplies the first number by the second number for an integer result
*Extracts the 100s digit of the fourth number
*If the third number is not equal to zero, divides the second number by the third number to get the integer result.
*Multiplies the third number by the fourth number to get a double result
*If the first number is not zero, divides the third number by the first number to get a double result
*Floating point sum of the input numbers
*Floating point average of the input numbers
*Prints a table of the input and the results
*The first column should be the description of the value or calculation, left aligned in a column 28 wide.
*The second column should display the value or result, right aligned in a field 14 wide.
*All float or double numbers should be displayed to three digits of precision.
*If the result would be invalid because of a divide by zero, the program should not do the divide, instead it should print the result DIV/0 instead.
Example of what is it suppose to look like
Enter three integers and a floating point number then press enter: 123 -456 524 -987.6
Description Data
------------------------------------------
Input 1 (int) 123
Input 2 (int) -456
Input 3 (int) 524
Input 4 (float) -987.600
Input 1 + Input 3 (int) 647
Input 1 * Input 2 (int) -56088
Hundreds Digit of Input 4 9
Input 2 / Input 3 (int) 0
Input 3 * Input 4 (double) -517502.387
Input 3 / Input 1 (double) 4.260
Sum of the input (float) -796.600
Average of the input (float) -199.150
its not showing the correct spacing for the tables not too worried bc i know how to space properly... i think