Upload
shahzaibusman
View
212
Download
0
Embed Size (px)
DESCRIPTION
Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation, Programming Presentation,
Citation preview
FUNDAMENTAL PROGRAMMING
TOPICS:• C FUNCTION INTRODUCTION• C FUNCTION TYPES• C USER-DEFINED FUNCTION
FUNDAMENTAL PROGRAMMING
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 FUNCTION’S :
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 character4) Clrscr() : is used for clear screen.
2) USER DEFINED FUNCTION’S :
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>
• int sum(int , int); • int main()
• {
• 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);
• return 0;
FUNCTION DECLARATION
FUNCTION BODY
• }• //Definition of function sum• int sum(int a, int b)• {• int res;• res = a + b;• return ( res );• }
FUNCTION DEFINITION O
UTPUT
THE END