I've been trying to look elsewhere online, but the code I see is all very complicated compared to my knowledge level. I'm trying to create a program that does exactly this and I keep getting a "Segmentation fault" error after it asks for the two integers.
Please enter two integers: -1 3
Description Data
----------- ----
Input 1 -1
Input 2 3
Sum 2
Half of Input 1 -0.5
Half of Input 2 1.5
Quotient 0
Here's my code as it is currently, I know it's messed up, but I literally started last week and my teacher isn't helping. What all is causing this segmentation fault?
Code:
#include <stdio.h>
int main (void)
{
// create a and b variables aka local declarations
int a;
int b;
int Sum;
int Half_of_Input_1;
int Half_of_Input_2;
int Quotient;
// statements
printf("\nName: Herp Derp\n");
printf("\nPlease enter two integers:\n");
scanf("%d %d, &a, &b");
scanf("%d %d %d %d, &Sum, &Half_of_Input_1, &Half_of_Input_2, &Quotient");
//inputting of data
Sum = a + b;
Half_of_Input_1 = a / 2;
Half_of_Input_2 = b / 2;
Quotient = a / b;
// chart data
printf("%20c%20c", "Description Data");
printf("%20c%20c", "___________ ____");
printf("%20c%20d", "Input 1", a);
printf("%20c%20d", "Input 2", b);
printf("%20c%20d", "Sum", Sum);
printf("%20c%19.1f", "Half of Input 1", Half_of_Input_1);
printf("%20c%19.1f", "Half of Input 2", Half_of_Input_2);
printf("%20c%20d", "Quotient", Quotient);
return 0;
}