Learn How to Program in Cby Dr. Kristin Switala
|
|
Review: Arrays (a)
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( )
{
int time;
int dates[4] = { 1299, 1400, 1515, 1519, 1541 };
printf("\nThe Ottoman Empire was one of the most powerful in the history of the world.");
printf("\n\t\t%d conquered central Turkey", dates[0]);
printf("\n\t\t%d took southern Europe", dates[1]);
printf("\n\t\t%d captured the Middle East", dates[]);
printf("\n\t\t%d controlled North Africa", dates[3]);
printf("\n\t\t%d seized Hungary", dates[4]);
time = dates[4] - dates[0]
printf("\nIt took %d years for the Ottoman Empire to conquer the Mediterannean.\n", time);
}
|
|
|