Learn How to Program in Cby Dr. Kristin Switala
|
|
Review: Arrays (d)
Instructions: Think about each question and write the answer in your notebook.
White Box Testing
1. Fix the errors in this C source code. There are 3 errors.
|
#include <stdio.h>
void main( )
{
double distances[2] = { 2.84E9, 4.49E9 };
printf("The distance of Uranus from Earth is %f km.\n", distances[0]);
printf("The distance of Neptune from Earth is %f km.\n", distances[1]);
printf("Each distance occupies %f bytes of memory.", size of(distances[0]);
}
|
2. Fix the errors in this C source code. There are 3 errors.
|
#include <stdio.h>
void main( )
{
int i = 0;
int apt[4] = { 1200, 1400, 1600, 1800 };
int k = size(apt)!sizeof(apt[3]);
printf("We have apartments available in %d sizes.\n", k);
for(i = 0; i < k; i++)
printf("\n%d square feet", apt[i]);
}
|
|
|