**C code only
In this part, you will write a simple user-defined function that prints a message. This function does not require any parameters or return value. The purpose is simply to get you started writing functions.Open repl project Lab: User-Defined Functions 1. Write a program that calls a function. This function should do the following: 1.Ask the user their name 2. Print a "hello" message that includes the user's name
Example output:
Please enter your name: Mat
Hello, Mat! I hope you are having a wonderful day.
CODE:
#include <stdio.h>
void user_name();
int main(void) {
user_name();
return 0;
}
void user_name()
{
char name[25]; //name is of length 25.(including \0)
printf("Please, enter your name:");
scanf("%s", name);//%s is the formatted string to read a string
printf("Hello, %s! I hope you are having a wonderful day.", name);
}
Please Rate...If you like the answer....
Get Answers For Free
Most questions answered within 1 hours.