0% found this document useful (0 votes)
11 views

Fundamental Programming Fundamental Programming: Topics: C Function Introduction C Function Types C User-Defined Function

Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation,

Uploaded by

ShahzaibUsman
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Fundamental Programming Fundamental Programming: Topics: C Function Introduction C Function Types C User-Defined Function

Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation,

Uploaded by

ShahzaibUsman
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

FUNDAMENTAL PROGRAMMING

PROGRAMMING
FUNDAMENTAL
TOPICS:

C FUNCTION INTRODUCTION
C FUNCTION TYPES
C USER-DEFINED FUNCTION

MADE BY:
PARHAM AILIA
HISHAM YAQOOB
SANA JAWED
JAHANZEB USMAN
SHEIKH MUHAMMAD AL AMIN UL QADRI
KULDEEP KUMAR

WHAT ARE FUNCTIONS?


A function is a group of statements that
together perform a task. Every c program
has at least one function which is main(),
and the most trivial programs can define
additional functions.

WHY DO WE USE FUNCTION ??


Functions are used normally in those
programs where some specific work is
required to be done repeatedly and looping
fails to do the same. We have to declare
and define the group of statement just
once and then whenever we need it, we
will call it in a function body.

TYPES OF FUNCTIONS :

There are two types of functions.


1) Built in functions.
2) User Defined functions.

1) BUILT IN FUNCTIONS:
The functions those are provided by c language
are refers to the Built in functions.
For Example :

1) Printf() : is used for displaying output in c.


2) Scanf() : is used for taking input in c.
3) Getch() : is used for wait until the user enters a
character

4) Clrscr() : is used for clear screen.

2) USER DEFINED
FUNCTIONS :
A user defined function is a function which is defined by a user.
This function are made to recall a code repeatedly and it saves both
users time and space. There are three elements of user defined
functions:

1.

Function Declaration

Syntax: Return-type Function name(parameter list);


2. Function Body
3. Function Definition

COMPLETE EXAMPLE OF USER-DEFINE


FUNCTION:

#include<stdio.h>

intsum(int,int);

int main()

FUNCTION
DECLARATION

int x,y,result;

printf("Enter value of x and y: ");

scanf("%d %d", &x, &y);

result=sum(x, y); //calling of function-sum

printf("Sum of %d + %d = %d",x,y,result);

return0;

FUNCTION
BODY

}
//Definition of function sum
intsum(inta,intb)
FUNCTION
DEFINITION
{
int res;
res = a + b;
return( res );
}

O
U
T
P
U
T

THE END

You might also like