#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, calc2, calc3, calc4;
double calc5, calc6;
float calc7, calc8;
printf("\nHello World! My name is Daniel Greene\n");
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;
return ;
}

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 Description :-28%14.2d\n", Data);
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***

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

For starters, line 16 and 18 are incorrect. To call a function you need ( and ), such as getInput(); You also have to add all the necessary parameters, such as those that calculate() require.

 * Output: Outout ia the data table thats prints out along with the hello world!
 */

#include <stdio.h>
void greeting(void);
int getInput();
int 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, calc2, calc3, calc4;
double calc5, calc6;
float calc7, calc8;

void greeting();

int getInput();

int 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);
return ;
}

void greeting ()
{
return printf("\nHello World! My name is Daniel Greene\n") ;
}




int 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 ;
}

int 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 = ((int) num4/100 %10) * -1;
}
else
{
     calc3 = ((int) num4/100) %10;
}
calc4 = num2/num3;
calc5 = num3 * num4;
calc6 = num3/num1;
calc7 = num1 + num2 + num3 + num4;
calc8 = calc7 / 4;
return calc1, calc2, calc3, calc4, calc5, calc6, calc7, calc8;
}

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)
{

printf("\n Description :-28%14.2d\n", "Data");
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 ; 
}

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

I fixed the code so there aren't any errors but it wont run.. any help?

Lines 24 and 26 are not calling the functions. Those two lines are just function prototypes, just like lines 7 and 8.

To call a function you leave out the data types. Example function call: calculate (num1, num2, num3, num4)

Unrelated to the actual functioning of the code, you'll want to change this little gem:

scanf("%d %d %d %d" , &num1, &num2, &num3, &num4);

The last %d should be %f, otherwise it won't read past the decimal point, and you'll be left with an int.

http://www.gidnetwork.com/b-63.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.