C simple program doesn't work

c, gcc

Solution

All of your scanfs read the variable lower.

scanf("%d", &lower);

This is very typical when you copy and paste sections of code. Welcome to C we hope you grow to love it as much as the rest of us.

Problem

Hello everyone! I'm trying to learn C language and have this trouble: Example code from book works as it should work: ``` #include <stdio.h> /* печать таблицы температур по Фаренгейту и Цельсию для fahr = 0, 20, ..., 300 */ main() { int fahr, celsius; int lower, upper, step; lower = 0; /* нижняя граница таблицы температур */ upper = 300; /* верхняя граница */ step = 20; /* шаг */ fahr = lower; while (fahr <= upper) { celsius = 5 * (fahr-32) / 9; printf("%d\t%d\n", fahr, celsius); fahr = fahr + step; } } ``` Output: 0 -17 20 -6 40 4 60 15 80 26 100 37 120 48 140 60 160 71 180 82 200 93 220 104 240 115 260 126 280 137 300 148 But code that I've written doesn't do anything!: ``` #include <stdio.h> main() { int fahr, celsius, lower, upper, step; printf("Enter lower temperature:"); scanf("%d", &lower); printf("Enter upper limit:"); scanf("%d", &lower); printf("Enter step:"); scanf("%d", &lower); fahr = lower; while (fahr <= upper) { celsius = 5 * (fahr-32) / 9; printf("%d\t%d\n", fahr, celsius); fahr = fahr + step; } } ``` Output: $ gcc fahr.c -o fahr.out $ ./fahr.out Enter lower temperature:0 Enter upper limit:300 Enter step:20 $ What's wrong?

Original source