C Language
Publish Date: April, 26-2019
Functions are an essential part of C programming that help make programs modular and reusable. In this example, we demonstrate a Type 1 function — a function with no arguments and no return type. Such functions do not take input parameters or return any value to the calling function. All operations are performed inside the function itself.
The following program defines a simple sum() function that takes two numbers as input and displays their sum. It uses Turbo C/C++ features like clrscr() and getch() for screen handling.
#include <stdio.h>
#include <conio.h> // Used for clrscr() and getch() in Turbo C/C++
// 1. Function Declaration (Prototype)
void sum(void);
int main() {
// clrscr(); // Clears screen in Turbo C/C++
printf("--- Main Program Starts ---\n");
// Function Call
sum();
printf("\n--- Main Program Ends ---\n");
// getch(); // Holds screen in Turbo C/C++
return 0;
}
// 2. Function Definition
void sum(void) {
int a, b, c;
printf("Enter the first number (a): ");
scanf("%d", &a);
printf("Enter the second number (b): ");
scanf("%d", &b);
c = a + b;
printf("The sum (a + b) is: %d", c);
}
Function Declaration:
void sum(void); tells the compiler that the function sum exists and takes no parameters.
Function Call:
In main(), the function sum() is called. The control jumps to the sum() function.
Function Definition:
Inside the function, variables a, b, and c are declared. The program takes input for a and b, adds them, and displays the result.
Turbo C/C++ Functions:
clrscr() clears the output screen.
getch() holds the screen until a key is pressed.
This is one of the simplest examples of function type 1 (no arguments, no return type) in C.
Business Services and Certifications
Bulk WhatsApp Marketing Services
Social Media Marketing Services
YouTube Marketing Services
Publish Date: April, 24-2026
Digital Marketing
Publish Date: April, 20-2026
Digital Marketing Services
Publish Date: April, 09-2026