10
FUNDAMENTAL PROGRAMMING TOPICS: C FUNCTION INTRODUCTION C FUNCTION TYPES C USER-DEFINED FUNCTION FUNDAMENTAL PROGRAMMING

Programming Presentation

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Programming Presentation

FUNDAMENTAL PROGRAMMING

TOPICS:• C FUNCTION INTRODUCTION• C FUNCTION TYPES• C USER-DEFINED FUNCTION

FUNDAMENTAL PROGRAMMING

Page 2: Programming Presentation

MADE BY:• PARHAM AILIA

• HISHAM YAQOOB

• SANA JAWED

• JAHANZEB USMAN

• SHEIKH MUHAMMAD AL AMIN UL QADRI

• KULDEEP KUMAR

Page 3: Programming Presentation

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.

Page 4: Programming Presentation

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.

Page 5: Programming Presentation

TYPES OF FUNCTION’S :

There are two types of functions.

1) Built in functions.

2) User Defined functions.

Page 6: Programming Presentation

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.

Page 7: Programming Presentation

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

Page 8: Programming Presentation

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

Page 9: Programming Presentation

• }• //Definition of function sum• int sum(int a, int b)• {•   int res;•   res = a + b;•   return ( res );• }

FUNCTION DEFINITION O

UTPUT

Page 10: Programming Presentation

THE END