Learn How to Program in Cby Dr. Kristin Switala
|
|
Review: Strings (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>
#include<string.h>
void main( )
{
char initial;
printf("What your first initial? ");
scanf(" %c", &initial);
if(alpha(initial) != 0)
printf("You should've typed only letters.");
else
printf("%c is your initial.", initial);
}
|
2. Fix the errors in this C source code. There are 2 errors.
|
#include<stdio.h>
#include<type.h>
void main( )
{
char initial;
printf("What your first initial? ");
scanf(" %c", &initial);
if(isuper(initial) == 0)
printf("You should've used an upper case letter.");
else
printf("%c is your initial.", initial);
}
|
|
|