Jeremy Alvin
Jeremy Alvin

Reputation: 9

Variables and Arithmetic Expressions C language

Hello I'm new to C and am using a book called The C programming language by Brian W.Kernighan 2nd Edition.

In chapter 1.2 there's a practice on how to use the formula Celsius = (5/9)(Fahrenheit-32) to print a table with Fahrenheit temperatures and celsius equivalent.

I am unable to figure what the error message meant. Is there a problem with my code? Or is it the compiler problem? Since I put it in the same folder as my other program. I'm using Visual studio btw and I don't know how to save the new program in a new folder. Everytime I tries to make a new folder and save it there they said path not found. Thus, me making programs in the same folder

The code that I write as follows:

#include <stdio.h>

/* print Fahrenheit-Celsius table
for fahr = 0, 20, ...,300 */
main()
{
    int fahr, celsius;
    int lower, upper, step;
    lower = 0;   /* lower limit of temperature table */
    upper = 300; /* upper limit */
    step = 20;   /* step size */

    fahr = lower;
    while (fahr <= upper) {
        celsius = 5 * (fahr - 32) / 9;
        printf("%d\t%d\n", fahr, celsius);
        fahr = fahr + step
    }
}

The output is as follows https://i.sstatic.net/RkANS.png

Upvotes: 0

Views: 87

Answers (2)

knightx
knightx

Reputation: 31

The file name cannot contain spaces.

Try renaming the file from Variable and Artithmetic.c to Variable_and_Arithmetic.c

Upvotes: 3

Tushar Adhatrao
Tushar Adhatrao

Reputation: 33

compiler is thinking that 'variable', 'and', 'arithmetic' are three different arguments. Change filename into something that does not contain any spaces.

Upvotes: 2

Related Questions