Name:________________________Netid:_______________Section:_______
________________ ______________________
___________________________________
____________________________
___________________________________
___________________________________
_____________________________________________________
_____________________________________________________
}
_____________________________________________________
Complete the following program that prompts a user for her
first name and then reads the name and responds with a
personal greeting.
For example:
Enter your first name: Sue
Hello Sue !
#include <stdio.h>
#include <string.h>
void main(void)
{
char fname[72];
char greeting[132];
printf("Enter your first
name: ");
scanf("%s",
________________________________);
strcpy(greeting , "Hello
");
strcat(greeting , fname);
strcat(greeting , " !");
printf(" %s \n",
greeting);
}
_____________________________________________________
Circle the correct Answer
a. int addTen(int x[ ]);
b. int addTen(int y);
c. int AddTen( int);
d. void plus_ten( int);
_______________________________________
_______________________________________
_______________________________________
_______________________________________
_______________________________________
To see how variables are modified in by functions in c, write the output when the following program executes.
#include <stdio.h>
void dosumpin(int a, double b[]); /* prototype */
int didsumpin(int d, double e[]); /* prototype */
void main(void)
{
int a = 1;
int c;
double b[2] = {2.0,1.0};
dosumpin(a,b);
printf("a = %i b[0] = %lf b[1] = %lf\n",a, b[0], b[1]);
dosumpin(a,b);
printf("a = %i b[0] = %lf b[1] = %lf\n",a, b[0], b[1]);
b[0] = 2.0;
b[1] = 1.0;
c = didsumpin(a,b);
printf("a = %i b[0] = %lf b[1] = %lf c = %i\n",a , b[0], b[1], c);
}
/* Note dosumpin assigns a value to the integer (a) (a = 8;), but the value of (a) in main is unmodified. However the changes to the array (b) are carried through to main*/
void dosumpin(int a, double b[])
{
b[0] = b[0] + a;
b[1] = b[1] + a;
a = 8;
}
int didsumpin(int d, double e[])
{
e[0] = e[0] + d;
e[1] = e[1] + d;
return 2*d;
}
a = ________________ b[0] = _______________ b[1] =
_______________
a = ________________ b[0] =
_______________ b[1] = _______________
a =
________________ b[0] = _______________ b[1] = _______________ c =
_________________
How many times does the word 'the'
appear? (Exact Match)
___________________
How many occurrence of 'the' are there?
(Partial Match)
___________________
What is the average length of the words
in the file illini.txt ?
___________________