Learn How to Program in C

by
Dr. Kristin Switala

Introduction

Directives

Variables

Conditionals

Loops

Arrays

Pointers

Strings

Functions

Structures


Site Map

Review: Variables (c)

Instructions: Think about each question and write the answer in your notebook.


General Questions

1. What format specifier do we use with short variables?

2. What format specifier do we use with long variables?

3. What format specifier do we use with double variables?

4. What do we use in C to mean exponent?


White Box Testing

1. Fix the errors in this C source code. There are 2 errors.

#include <stdio.h>
void main( )
{
long number = 654321;
long result;
result = number * 2;
printf("\nIf you double %d you get %d", number, result);
}

2. Fix the errors in this C source code. There are 3 errors.

#include <stdio.h>
void main( )
{
double uranus = 2.84E9;
double neptune = 4.49F9;
double distance;
distance = neptune - uranus;
printf("\nUranus is %d km from Earth.", uranus);
printf("\nNeptune is %11.0f km from Earth.", neptune);
printf("\nThis means that Neptune is %f km from Uranus.", distance);
}

Copyright
© 2001
Kristin Switala
Hosted by www.Geocities.ws

1