C Programming – Day 7 | Functions in C Definition, Types & Examples for Beginners
FUNCTIONS IN C
DAY - 7
✅ We keep learning without stopping 🚀
📍 Day-7 — Functions in C
Today we will learn:
✅ What is a function?
✅ Types of functions
✅ Function declaration, definition, calling
✅ Passing arguments
✅ Return values
✅ Task + Quiz
✅ 1️⃣ What is a Function?
📌 A function is a block of code that performs a specific task
📌 Written once — used many times ✅
Example:
✅ 2️⃣ Function Structure
Example: Function that returns sum
✅ 3️⃣ Function with Parameters & Return
✅ 4️⃣ Function Prototype (Declaration)
📌 Write before main() if function defined below
✅ 5️⃣ Types of Functions
| Type | Example |
|---|---|
| No parameter, No return | void hello() |
| Parameter, No return | void print(int x) |
| No parameter, Return value | int roll() |
| Parameter, Return value | int add(int a,int b) |
🧪 Practice Example: Check Even or Odd (Function)
✅ Task-7
Write a program to:
✔ Create a function named isPrime(int n)
✔ Return:
-
1→ Prime -
0→ Not Prime
✔ In main(), input a number and check prime or not
Example Output:
📌 Hint:
-
Prime number has only 2 divisors
-
Use loop from 2 to n/2
✅ Submit your code — I will correct if needed
📝 Quick Quiz — Day-7
Reply like: 1A, 2C, 3B
1️⃣ A function that returns nothing uses:
A) void
B) int
C) float
2️⃣ Which contains the main execution of program?
A) sum()
B) printf()
C) main()
3️⃣ Function prototype is written to:
A) reduce memory
B) tell compiler about function before use
C) stop execution
🎯 After you finish Day-7:
➡ We start Day-8: Pointers 🔥
Whenever you’re ready — send:
👉 Task-7 Code
👉 Day-7 Quiz Answers
I’m here with you till complete success! ✅💪

No comments
Thank You For Visit My Website.
I Will Contact As Soon As Possible.