lesson 8 getscore c
[[lesson_8_getscore_c]] last edit on Aug 10, 2005 3:35 AM by rescued_by_c

[user02@FC4 Lesson08]$ cat -n getscore.c
   1  #include <stdio.h>
   2
   3  int main(void)
   4  {
   5     int test_score;
   6
   7     printf("Type in the test score and press Enter: ");
   8     scanf("%d", &test_score);
   9
  10     if (test_score >= 90)
  11        {
  12           printf("Congratulations, you got an A!\n" );
  13           printf("Your test score was %d\n", test_score );
  14        }
  15     else
  16        {
  17           printf("You should have worked harder!\n" );
  18           printf("You missed %d points\n", 100 - test_score);
  19        }
  20
  21     return 0;
  22  }
[user02@FC4 Lesson08]$ gcc -o getscore getscore.c
[user02@FC4 Lesson08]$ ./getscore
Type in the test score and press Enter: 100
Congratulations, you got an A!
Your test score was 100
[user02@FC4 Lesson08]$ ./getscore
Type in the test score and press Enter: 69
You should have worked harder!
You missed 31 points