Question: Type the following program and run it. #include #include int main(void) { char name[80]; printf(Enter your full name : ); gets(name); printf( Your name is
- Type the following program and run it.
#include
#include
int main(void)
{
char name[80];
printf("Enter your full name : ");
gets(name);
printf(" Your name is %s ", name);
system(pause);
return (0);
}
- For the above program, what happens if you use scanf to enter the full name? Why?
- Modify the program to print your name using a function.
- Modify the program to count the number of characters in the name and display both the name and the number of characters. Do not count spaces as characters. The ASCII code for a space is 3210 or ' ' as a character. The program must have two separate functions to count the number of characters and to display the result.
- Modify the program to the strlen function in the string.h library rather than the character counting function. Note that the number of characters now includes spaces.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
