1. ## Criticize this please... infinite loop idk why

Code:
```#include <stdio.h>
#include <stdlib.h>

double subfunc(double a, double b);       //Subtract function
double divfunc(double a, double b);       //Divide function
double multifunc(double a, double b);     //Multiply function
void inputfunc(double *a, double *b);   //Input from console function
void calculate(double *a, double *b);   //Choice of operation and calling function

int main()
{

double answer1 = 0;                     //Holds first value inputted
double answer2 = 0;                     //Holds second value inputted

}

{
return a+b;
}

double subfunc(double a, double b)          //Subtracts two numbers
{
return a-b;
}

double divfunc(double a, double b)          //Divides two numbers
{
return a/b;
}

double multifunc(double a, double b)         //Multiplies two numbers
{
return a*b;
}

void inputfunc(double *a, double *b)         //function to provide input
{

double temp1 = .12351;                        //temp1 default value
double temp2 = .12351;                      //temp1 default value

do                                            //do loop continues to repeat if default value are not changed
{

scanf("%l",&temp1);                        //Collect console input assign to temp1

scanf("%l",&temp2);                      //Collect console input assign to temp2

}
while(temp1 == .12351 || temp2 == .12351);

*a = temp1;                                    //pass values collected back
*b = temp2;                                    //pass values collected back

return;
}

void calculate(double *a, double *b)            //calculate function that asks for input on operation and calculate/outputs result
{

char operation = 'Z';                    //preset value also used in while loop
double temp1 = *a;                      //temp var to hold passed value
double temp2 = *b;                        //temp var to hold passed value

while (operation == 'Z')                //while loop to keep entry going if value entered doesnt meet if statement condition
{
printf("\nWhich operation would you like to use?(A/S/M/D/(Q)uit): "); //prompt for user to enter operation
operation = getchar();                                                  //operation collecting input

if (operation != 'A' || operation != 'S' || operation != 'M' || operation != 'D' || operation != 'Q')  //checking for bad input
{
continue;                                                                                           //if bad input continues loop
}
else
{
switch (operation)                                                                                //switch statement that takes choice and calc/output result
{
case 'A':
break;
case 'S':
printf("Result: %lf",subfunc(temp1,temp2));
break;
case 'M':
printf("Result: %lf",multifunc(temp1,temp2));
break;
case 'D':
printf("Result:  %lf",divfunc(temp1,temp2));
break;
case 'Q':
return;
}
}
operation = 'Z';                                                                                    //resets var to allow for looping on bad input

}
return;
}```

2. Look at the following snippet:
Code:
```operation = getchar();                                                  //operation collecting input

if (operation != 'A' || operation != 'S' || operation != 'M' || operation != 'D' || operation != 'Q')  //checking for bad input```
Let's assume that you entered 'A' in the first line. Since operation is equal to 'A' the not equal to 'A' is false, but 'A' is not equal to 'S'.

Also you should re-read your documentation for scanf(). What is the proper format specifier for a double?
Code:
```    double temp1 = .12351;                        //temp1 default value
...

scanf("%l",&temp1);```
Jim

Code:
```main.c||In function 'inputfunc':|
main.c|73|warning: conversion lacks type at end of format|
main.c|73|warning: too many arguments for format|
main.c|76|warning: conversion lacks type at end of format|
main.c|76|warning: too many arguments for format|
main.c||In function 'main':|
main.c|33|warning: control reaches end of non-void function|
||=== Build finished: 0 errors, 5 warnings ===|```
Code:
```printf("Enter your first number: ");    //Ask for input
scanf("%lf",&temp1);                        //Collect console input assign to temp1

scanf("%lf",&temp2);```

4. Code:
```#include <stdio.h>
#include <stdlib.h>

double subfunc(double a, double b);       //Subtract function
double divfunc(double a, double b);       //Divide function
double multifunc(double a, double b);     //Multiply function
void inputfunc(double *a, double *b);   //Input from console function
void calculate(double *a, double *b);   //Choice of operation and calling function

int main()
{

double answer1 = 0;                     //Holds first value inputted
double answer2 = 0;                     //Holds second value inputted

return 0;

}

{
return a+b;
}

double subfunc(double a, double b)          //Subtracts two numbers
{
return a-b;
}

double divfunc(double a, double b)          //Divides two numbers
{
return a/b;
}

double multifunc(double a, double b)         //Multiplies two numbers
{
return a*b;
}

void inputfunc(double *a, double *b)         //function to provide input
{

double temp1 = .12351;                        //temp1 default value
double temp2 = .12351;                      //temp1 default value

do                                            //do loop continues to repeat if default value are not changed
{

scanf("%lf",&temp1);                        //Collect console input assign to temp1

scanf("%lf",&temp2);                      //Collect console input assign to temp2

}
while(temp1 == .12351 || temp2 == .12351);

*a = temp1;                                    //pass values collected back
*b = temp2;                                    //pass values collected back

return;
}

void calculate(double *a, double *b)            //calculate function that asks for input on operation and calculate/outputs result
{

char operation = 'Z';                    //preset value also used in while loop
double temp1 = *a;                      //temp var to hold passed value
double temp2 = *b;                        //temp var to hold passed value

while (operation == 'Z')                //while loop to keep entry going if value entered doesnt meet if statement condition
{
printf("\nWhich operation would you like to use?(A/S/M/D/(Q)uit): "); //prompt for user to enter operation
operation = getchar();                                                  //operation collecting input

if (operation == 'A' || operation == 'S' || operation == 'M' || operation == 'D' == operation == 'Q')  //checking for bad input
{
switch (operation)                                                                                //switch statement that takes choice and calc/output result
{
case 'A':
break;
case 'S':
printf("Result: %lf",subfunc(temp1,temp2));
break;
case 'M':
printf("Result: %lf",multifunc(temp1,temp2));
break;
case 'D':
printf("Result:  %lf",divfunc(temp1,temp2));
break;
case 'Q':
return;
}
}
else
{
operation = 'Z';
continue;
}
//resets var to allow for looping on bad input

}
return;
}```
Thank you for the help. These errors were driving me nuts.

I am now trying to figure out why this line is doubling itself:

Code:
```printf("\nWhich operation would you like to use?(A/S/M/D/(Q)uit): "); //prompt for user to enter operation
operation = getchar();
```

5. in line 83 you better check return values of scanf to control your loop

in line 104 - getchar returns int - so you can check the return value for EOF before treating it as char

in line 106
Code:
`operation == 'D' == operation == 'Q'`
Why do you need to pass pointers to your calculate function?