C programming function
In this tutorials, you will learn-
Function-
Function is defined as to perform a particular task. In another word, a function is a group of statements that together perform a task.
There are some characteristics of function-
1 Reusability of code.
2 Reduce the complexity and reduce the size of the program
3 Easy to resolve and issue (easy to debug).
Function-
Function is defined as to perform a particular task. In another word, a function is a group of statements that together perform a task.
Types of function:-
There are basically two types of functions which are available in c language...
1 predefine function
2 user define function
1 Predefine function:- A predefine function are those function which already exists in the library
For e.g clrscr( ); , getch() , printf () , scanf() ,etc
2 Userdefine function:- A function that is defined by user aa per the requirement is known as user define function.
Types of user define function :-
There are three types of user define function are:-
1 Prototype
2 Calling of function----------------* call by value.
* call by reference.
3 Body or definition of the function.
1 Prototype:- This is one of the most important part of user define. It is also known as a declaration of function means the name of the function number of argument and type of argument in the function and output type of a function means return value.
For e.g syntax
return type function name (agruments);
output value
int sum (int,int );
2 calling of function:- During the function call a function may accept one or more input as argument , process them and return the result to the calling program
It can be two types are- * Call by value.
* Call by reference.
3 Body or definition of function:- A bod of a function consist of statement which are going to perform a specific task. Afunction body consist of a single or block of statement.It is also a mandatory part of a function.
syntax int sum(int x, int y)
{
int c;
c=x+y;
return(c);
}
The basic structure of defining a user define function:-
# <header file>
#<header file>
function prototype -------------------------------- 1
void main()
{
function call ; ------------------------------------- 2
getch();
}
function body; -------------------------------------- 3
#include<stdio.h>
#include<conio.h>
int sum(int,int,int);
void main()
{
int x=2,y=3,z=4,total;
total=sum(x,y,z);
printf("total is =%d",total);
getch();
}
int sum(int a,int b,int c)
{
int d;
d=a+b+c;
return(d);
}
OUTPUT
total is =9
For example
#include<stdio.h>
#include<conio.h>
int sum(int,int,int);
void main()
{
int x=2,y=3,z=4,total;
total=sum(x,y,z);
printf("total is =%d",total);
getch();
}
int sum(int a,int b,int c)
{
int d;
d=a+b+c;
return(d);
}
OUTPUT
total is =9
condition with function :-
( mannar of writing a function )
( mannar of writing a function )
1 Function with argument & with return value.
2 Function with argument & number of return value .
3 Function with argument & with return value .
3 Function with no argument value & no return value
Now, one example of function with argument & no return value which make more clear this topic..
so,,
#include<stdio.h>
#include<conio..h >
void table(int);
void mian()
{
int n;
printf("enter any no");
scanf("%d",&n);
void table(n);
getch();
}
void table(int x)
{
int t, i;
for(i=1;i<=10;i++)
{
t=i*x;
printf("%d=%d*%d",x,i,t);
}
}
OUTPUT
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20
So, friends, this is the information related to the topic function C programming In our next post, we discuss the call by value and call by reference in detail... so please read our next blog to know more about a function
2 Function with argument & number of return value .
3 Function with argument & with return value .
3 Function with no argument value & no return value
Now, one example of function with argument & no return value which make more clear this topic..
so,,
#include<stdio.h>
#include<conio..h >
void table(int);
void mian()
{
int n;
printf("enter any no");
scanf("%d",&n);
void table(n);
getch();
}
void table(int x)
{
int t, i;
for(i=1;i<=10;i++)
{
t=i*x;
printf("%d=%d*%d",x,i,t);
}
}
OUTPUT
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20
c programming language
c programming for prime number
c programming basics
c programming structure
c programming tutorial
c programming array
c programming questions for interview
c programming pdf
for c programming example
c programming examples
c programming questions
c programming interview questions
c programming hello world
what c programming
c programming online compiler
c programming functions
c programming string
c programming online
c programming com…
c programming language
c programming for prime number
c programming basics
c programming structure
c programming tutorial
c programming questions for interview
c programming pdf
for c programming example
c programming examples
c programming questions
c programming interview questions
c programming hello world
what c programming
c programming online compiler
c programming functions
c programming string
c programming online
c programming compiler
c programming in vs code
how learn c programming
c programming software
c programming reverse number
c programming for loop
c programming practice
c programming for beginners
c programming examples with output
c programming recursion
So, friends, this is the information related to the topic function C programming In our next post, we discuss the call by value and call by reference in detail... so please read our next blog to know more about a function
0 comments:
Post a Comment
If you have any doubt, please let me know