Learn How to Program in C

by
Dr. Kristin Switala

Introduction

Directives

Variables

Conditionals

Loops

Arrays

Pointers

Strings

Functions

Structures


Site Map

Answers to Review: Variables (a)


General Questions

1. 432

2. 2

3. %d

4. scanf

5. the ampersand (&)


Integer Variables

1. four errors:

  • line 1 has two errors; it should be: #include <stdio.h>
  • line 5 should end with a semicolon ;
  • line 6 should have a close curly brace }

2. three errors:

  • line 2 should be: void main( )
  • line 3 should be open curly brace: {
  • the variable at the end of line 4 should be articles instead of parts

3. two errors:

  • line 1 should have <stdio.h>
  • line 2 should have parentheses after main ( )

4. three errors:

  • line 5 should be: printf ("\nNigeria achieved independence in %d.\n", year);

Working with Viewer Input

1. four errors:

  • line 4 should be: int age;
  • line 6 has two errors; it should be: scanf("%d", &age);
  • line 7 should have %d

2. three errors:

  • line 5 should have " before the )
  • line 6 should have %d
  • line 7 should end with , sisters

Arithmetic Operators

1. two errors:

  • line 8 should be: time = current - 1957;
  • line 9 should end in a semicolon ;

2. three errors:

  • should initialize another variable: int average;
  • line 8 should end with , end);
  • line 9 should say beginning
Copyright
© 2001
Kristin Switala
Hosted by www.Geocities.ws

1