0
0
Cprogramming~15 mins

Function calling - Mini Project: Build & Apply

Choose your learning style9 modes available
Function calling
📖 Scenario: You are creating a simple program to greet a user by name. The greeting message will be generated by a function.
🎯 Goal: Build a C program that defines a function to print a greeting message and then calls that function from main.
📋 What You'll Learn
Define a function called greet that takes no parameters and returns nothing.
Inside greet, print the message Hello, friend!.
Call the greet function from the main function.
💡 Why This Matters
🌍 Real World
Functions help organize code into reusable blocks, making programs easier to read and maintain.
💼 Career
Understanding function calling is essential for any programming job, as it is a basic building block of software development.
Progress0 / 4 steps
1
Create the greet function
Write a function called greet that takes no parameters and prints Hello, friend! using printf.
C
Need a hint?

Use void greet() to define the function and printf to print the message.

2
Call the greet function from main
Inside the main function, call the greet function by writing greet(); before return 0;.
C
Need a hint?

Simply write greet(); inside main before return 0;.

3
Add a function prototype for greet
Add a function prototype for greet above main by writing void greet();.
C
Need a hint?

Write the prototype void greet(); before the function definitions.

4
Run the program and print the output
Run the program and print the output by writing printf output to the console. The program should print Hello, friend!.
C
Need a hint?

The greet function already prints the message. Just run the program to see the output.