Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

C exam guaranteed full mark

Rating
-
Sold
-
Pages
43
Uploaded on
05-06-2025
Written in
2024/2025

Looking for easy-to-understand C Programming notes that help you score better in exams and understand core concepts faster? These notes are student-friendly, made with clarity, simplicity, and exactly what you need for university exams and assignments. What’s Included: • Complete coverage of C basics to advanced • Well-structured notes for each unit/module • Key programs with example outputs • Short notes for revision and viva • Clean formatting for easy reading • Includes frequently asked questions

Show more Read less
Institution
Course

Content preview

S2-GXEST 204-PROGRAMMING IN C (2024 Scheme)

Module 3 - Syllabus
• Functions - Function definition, Function call, Function prototype, Parameter
passing; Recursion; Passing array to function;
• Macros - Defining and calling macros;
• Command line Arguments.
• Structures - Defining a Structure variable, Accessing members, Array of
structures, Passing structure to function; Union.
• Storage Class - Storage Classes associated with variables: automatic, static,
external and register.

C Functions
• A function in C is a set of statements that when called perform some specific
tasks. A function is a block of code which only runs when it is called.
• It is the basic building block of a C program that provides modularity and code
reusability.
• Functions are used to perform certain actions, and they are important for
reusing code: Define the code once, and use it many times.
• You can pass data, known as parameters, into a function.

Consider a simple C program

#include <stdio.h>
int main()
{

int add;
add=10+30;

printf("Sum is: %d", add);
return 0;
}

Same program using functions

#include<stdio.h>

//function declaration
int sum(int a, int b);

int main()
{
// Calling sum function and

S2-GXEST 204-PROGRAMMING IN C (2024 Scheme) Reenu Renjith - Assistant Professor CSE - MBITS 1

, // storing its value in add variable
int add = sum(10, 30);

printf("Sum is: %d", add);
return 0;
}

//function definition
int sum(int a, int b)
{
return a + b;
}

Function Declarations/Function Prototype
• In a function declaration, we must provide the function name, its return type, and
the number and type of its parameters.
• A function declaration tells the compiler that there is a function with the given
name defined somewhere else in the program.
Syntax
return_type name_of_the_function (parameter_1, parameter_2);
The parameter name is not mandatory while declaring functions. We can also
declare the function without using the name of the data variables.
Example
int sum(int a, int b); // Function declaration with parameter names
int sum(int , int); // Function declaration without parameter names


#include<stdio.h>

//function declaration
int sum(int a, int b);

int main()
{
// Calling sum function and
// storing its value in add variable
int add = sum(10, 30);

printf("Sum is: %d", add);
return 0;
}

//function definition
int sum(int a, int b)

S2-GXEST 204-PROGRAMMING IN C (2024 Scheme) Reenu Renjith - Assistant Professor CSE - MBITS 2

,{
return a + b;
}

Function Definition
• The function definition consists of actual statements which are executed when
the function is called (i.e. when the program control comes to the function).
• Syntax:

return_type function_name (para1_type para1_name, para2_type para2_name)
{
// body of the function
}




• Either function can be declared first and then defined later in the program
• Or a function can be defined and declared in a single step also (but when we do
so, make sure the function definition is written before main program).
• The below example serves as both a function definition and a declaration.

#include<stdio.h>

//function definition and declaration together before main program
int sum(int a, int b)
{
return a + b;
}

int main()
{
// Calling sum function and
// storing its value in add variable
int add = sum(10, 30);

printf("Sum is: %d", add);
return 0;
}

S2-GXEST 204-PROGRAMMING IN C (2024 Scheme) Reenu Renjith - Assistant Professor CSE - MBITS 3

, Function Call
• A function call is a statement that instructs the compiler to execute the function.
• We use the function name and parameters in the function call.
• In the below example, the first sum function is called and 10,30 are passed to the
sum function.
• After the function call sum of a and b is returned and control is also returned
back to the main function of the program.




Conditions of Return Types and Arguments
• In C programming language, functions can be called either with or without
arguments and might return values.
• They may or might not return values to the calling functions.
1. Function with no arguments and no return value
2. Function with no arguments and with return value
3. Function with argument and with no return value
4. Function with arguments and with return value



Types of Functions
There are two types of functions in C:
1. Library Functions
2. User Defined Functions
1. Library Function
• A library function is also referred to as a “built-in function”.
• A compiler package already exists that contains these functions.
S2-GXEST 204-PROGRAMMING IN C (2024 Scheme) Reenu Renjith - Assistant Professor CSE - MBITS 4

Written for

Course

Document information

Uploaded on
June 5, 2025
Number of pages
43
Written in
2024/2025
Type
Class notes
Professor(s)
Alfariz
Contains
All classes

Subjects

$3.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
alfariz

Get to know the seller

Seller avatar
alfariz Mbits
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
11 months
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions