Issues with the scanf Function
I am working on a code for my C programming class, I am completely new to C programming. Everytime I follow all of the guidelines and copy exactly what the book examples are or an online tutorial says the scanf function returns gibberish numbers or the number 0. This is my code, can anyone help me figure out what it is that I am doing wrong please?
Code:
#include <stdio.h>
main(void)
{
/* Declares variables */
int a, b, f, x, y;
/* Initializes variables */
a = 0;
b = 0;
f = 0;
x = 0;
y = 0;
/* Asks the user for their input to determine the values of the variables a, b, x, and y */
printf("\nEnter the value for the variable a: ");
scanf("%d", &a);
printf("\nEnter the value for the variable b: ");
scanf("%d", &b);
printf("\nEnter the value for the variable x: ");
scanf("%d", &x);
printf("\nEnter the value for the variable y: ");
scanf("%d", &y);
f = ((a - b)*(x - y));
printf("%d", f);
}
I tried the code you gave me
I am using the cygwin compiler and it does not let me input the values even after I tried the code you gave me. For some reason it still outputs 0 after the last prompt.