SlideShare a Scribd company logo
Functions in C
WHAT IS C FUNCTION?
 A large C program is divided into basic building blocks called C
function.
 C function contains set of instructions enclosed by “{ }” which
performs specific operation in a C program.
 Every C program has at least one function, which is main().
WHAT IS C FUNCTION?
 A function declaration tells the compiler about a function's
name, return type, and parameters. A function definition provides
the actual body of the function.
 The C standard library provides numerous built-in functions that
your program can call. For example, strcat() to concatenate two
strings,
 A function can also be referred as a method or a sub-routine or a
procedure, etc.
USES OF C FUNCTIONS
 C functions are used to avoid rewriting same logic/code again
and again in a program.
 There is no limit in calling C functions to make use of same
functionality wherever required.
 A large C program can easily be tracked when it is divided into
functions.
 The core concept of C functions are, re-usability, dividing a big
task into small pieces to achieve the functionality and to
improve understandability of very large C programs.
Function declaration:
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
Example
return_type function_name (argument list);
Detailed concept of function  in c programming
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).
A C function is generally defined and declared in a single step because the
function definition always starts with the function declaration so we do not
need to declare it explicitly. The below example serves as both a function
definition and a declaration.
return_type function_name (arguments/parameter list)
{
Body of function;
}
Detailed concept of function  in c programming
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.
• The parameter list must not differ in function calling and function
declaration. We must pass the same number of functions as it is declared
in the function declaration.
Syntax
function_name (arguments/parameter list);
Detailed concept of function  in c programming
 Function definition:
return_type function_name (arguments list)
{
Body of function;
}
 Function call: function_name (arguments list);
 Function declaration:
return_type function_name (argument list);
FUNCTION DECLARATION, FUNCTION CALL AND FUNCTION DEFINITION
 There are 3 aspects in each C function. They are:
 Function declaration or prototype – This informs compiler about the
function name, function parameters and return value’s data type.
 Function call – This calls the actual function
 Function definition – This contains all the statements to be executed.
Detailed concept of function  in c programming
Detailed concept of function  in c programming
#include <stdio.h>
// Function declaration (prototype)
int add(int a, int b);
int main()
{
int num1 = 5;
int num2 = 7;
int result;
// Function call
result = add(num1, num2);
printf("The sum is: %dn", result);
return 0;
}
// Function definition
int add(int a, int b)
{
return a + b;
}
#include<stdio.h>
int square ( int ); // function prototype, also called function declaration
int main( )
{
int m, n ;
printf ( "nEnter some number for finding square n");
scanf ( "%d", &m ) ;
n = square (m) ; // function call
printf ("nSquare of the given number %d is %d",m,n );
}
int square ( int x ) // function definition
{
int p ;
p = x * x ;
return p;
}
TYPES OF FUNCTIONS
There are two types of functions in C programming:
Library Functions: are the functions which are declared in the C
header files such as scanf(), printf(), gets(), puts(), pow() etc.
User-defined functions: are the functions which are created by the
C programmer, so that he/she can use it many times. It reduces
the complexity of a big program and optimizes the code.
HOW TO CALL C FUNCTIONS IN A PROGRAM?
 There are two ways that a C function can be called from a program.
They are:
 Call by value
 Call by reference
Types of function parameters:
 Actual parameter – This is the argument which is used in function
call.
 Formal parameter – This is the argument which is used in function
definition
CALL BY VALUE
 In call by value method, the copy of the variable is passed to the
function as parameter.
 The value of the actual parameter can not be modified by formal
parameter.
 Different Memory is allocated for both actual and formal
parameters. Because, value of actual parameter is copied to formal
parameter.
Note:
#include<stdio.h>
void swap(int a, int b); // function prototype, also called function declaration
void main()
{
int m = 22, n = 44;
printf(" values before swap m = %d n and n = %d", m, n);
swap(m, n); //call by value
printf(" nvalues after swap m = %dn and n = %d", m, n);
getch();
}
void swap(int m, int n)
{
int tmp;
tmp = m;
m = n;
n = tmp;
printf(" nvalues after swap m = %dn and n = %d", m, n);
}
CALL BY REFERENCE
 In call by reference method, the address of the variable is
passed to the function as parameter.
 The value of the actual parameter can be modified by formal
parameter.
 Same memory is used for both actual and formal parameters
since only address is used by both parameters.
#include<stdio.h>
void swap(int *, int *); // function prototype, also called function declaration
void main()
{
int m = 22, n = 44;
printf("values before swap m = %d n and n = %d",m,n);
swap(&m, &n); // calling swap function by reference
printf("n values after swap m = %d n and n = %d", m, n);
getch();
}
void swap(int *a, int *b)
{
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
printf("n Swap function values after swap a = %d nand b = %d", *a, *b);
}
C - SCOPE RULES
 A scope in any programming is a region of the program where
a defined variable can have its existence and beyond that
variable it cannot be accessed.
 There are three places where variables can be declared in C
programming language −
 Inside a function or a block which is called local variables.
 Outside of all functions which is called global variables.
 In the definition of function parameters which are called formal
parameters.
LOCAL VARIABLES
 Variables that are declared inside a function or block are called
local variables.
 They can be used only by statements that are inside that
function or block of code.
 Local variables are not known to functions outside their own.
We can define the User defined functions in multiple ways
 Function with no argument and no Return value
 Function with no argument and with Return value
 Function with argument and No Return value
 Function with argument and Return value
Function with No argument and No Return value
In this method, We won’t pass any arguments to the function while
defining, declaring or calling the function. This type of functions will not
return any value when we call the function from main() or any sub
function. When we are not expecting any return value but, we need
some statements to be printed as output then, this type of functions are
very useful.
#include<stdio.h>
void Addition(); // Function Declaration
int main()
{
printf("n ............. n");
Addition(); // Function call
}
void Addition()
{
int Sum, a = 10, b = 20;
Sum = a + b;
printf("n Sum of a = %d and b = %d is = %d", a, b, Sum);
}
Function with no argument and with Return value
n this method, We won’t pass any arguments to the function while defining, declaring or calling the function.
This type of functions will return some value when we call the function from main() or any sub function.
Data Type of the return value will depend upon the return type of function declaration.
For instance, if the return type is int then return value will be int.
#include<stdio.h>
int Multiplication();
int main()
{
int Multi;
Multi = Multiplication();
printf("n Multiplication of a and b is = %d n", Multi );
return 0;
}
int Multiplication()
{
int Multi, a = 20, b = 40;
Multi = a * b;
return Multi;
}
Function with argument and No Return value
This method allows us to pass the arguments to the function while calling the function. But, This type of functions will not
return any value when we call the function from main () or any sub function.
#include<stdio.h>
int Addition(int, int);
Int main()
{
int a, b;
printf("n Please Enter two integer values n");
scanf("%d %d",&a, &b);
Addition(a, b);
}
int Addition(int a, int b)
{
int Sum;
Sum = a + b;
printf("n Additiontion of %d and %d is = %d n", a, b, Sum);
}
Function with argument and Return value
This method allows us to pass the arguments to the function while calling the function. This type of functions will return
some value when we call the function from main () or any sub function. Data Type of the return value will depend upon the
return type of function declaration. For instance, if the return type is int then return value will be int.
#include<stdio.h>
int Multiplication(int, int);
int main()
{
int a, b, Multi;
printf("n Please Enter two integer values n");
scanf("%d %d",&a, &b);
Multi = Multiplication(a, b);
printf("n Multiplication of %d and %d is = %d n", a, b,
Multi);
return 0;
}
int Multiplication(int a, int b)
{
int Multi;
Multi = a * b;
return Multi;
}
Recursion
A function that calls itself is known as a recursive function.And, this technique is known as recursion.
 In programming languages, if a program allows you to call a function inside the same function, then it
is called a recursive call of the function.
Syntax:
void recursion()
{
recursion(); /* function calls itself */
}
int main()
{
recursion();
}
Factorial using Recursion
#include <stdio.h>
int fact (int);
int main()
{
int n,f;
printf("Enter the number whose f
actorial you want to calculate?");
scanf("%d",&n);
f = fact(n);
printf("factorial = %d",f);
}
int fact(int n)
{
if (n==0)
{
return 0;
}
else if ( n == 1)
{
return 1;
}
else
{
return n*fact(n-1);
}
}
Detailed concept of function  in c programming
Advantages & Disadvantages of Recursion
Advantage
Recursion makes program elegant and cleaner.All algorithms can be defined recursively which makes it easier to visualize and prove.
Reduce unnecessary calling of function.
Disadvantage
If the speed of the program is vital then, you should avoid using recursion. Recursions use more memory and are generally slow.
Instead, you can use loop.
programmers need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.
Recursive solution is always logical and it is very difficult to trace.(debug and understand).
In recursive we must have an if statement somewhere to force the function to return without the recursive call being executed,
otherwise the function will never return.
Recursion takes a lot of stack space, usually not considerable when the program is small and running on a PC.
Recursion uses more processor time
• C Standard library functions or simply C Library functions are inbuilt functions in C programming.
• The prototype and data definitions of the functions are present in their respective header files, and must be
included in your program to access them.
Advantages of using standard library functions:
1. They work
These functions have gone through multiple rigorous testing and are easy to use.
2. The functions are optimized for performance
In the process, they are able to create the most efficient code optimized for maximum performance.
3. It saves considerable development time
Since the general functions like printing to a screen, calculating the square root, and many more are already written.
You shouldn't worry about creating them once again.
It saves valuable time and your code may not always be the most efficient.
3. The functions are portable
With ever changing real world needs, your application is expected to work every time, everywhere.
And, these library functions help you in that they do the same thing on every computer.
This saves time, effort and makes your program portable.
Library functions
#include <stdio.h>
#include <math.h>
int main()
{
float num, root;
printf("Enter a number: ");
scanf("%f", &num); // Computes the square root of num and stores in root.
root = sqrt(num);
printf("Square root of %.2f = %.2f", num, root);
return 0;
}
Some more examples of Library functions:
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
int main()
{
double num = 3.0;
double result;
result = atan(num);
printf("Inverse of tan(%.2f) = %.2f in radians",
num, result);
return 0;
}
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
int main()
{
double num = 0.0;
double result;
result = acos(num);
printf("Inverse of tan(%.2f) = %.2f in
radians", num, result);
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
int main()
{
double num = 2.0;
double result;
result = cos(num);
printf("Inverse of tan(%.2f) = %.2f in radians",
num, result);
return 0;
}
Ad

More Related Content

What's hot (20)

Conic Sections- Circle, Parabola, Ellipse, Hyperbola
Conic Sections- Circle, Parabola, Ellipse, HyperbolaConic Sections- Circle, Parabola, Ellipse, Hyperbola
Conic Sections- Circle, Parabola, Ellipse, Hyperbola
Naman Kumar
 
Stereochemistry
StereochemistryStereochemistry
Stereochemistry
Sirod Judin
 
Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...
Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...
Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...
Akhil Nagar
 
Medindo a robustez de uma rede com o fator de resiliência presentation ciaw...
Medindo a robustez de uma rede com o fator de resiliência   presentation ciaw...Medindo a robustez de uma rede com o fator de resiliência   presentation ciaw...
Medindo a robustez de uma rede com o fator de resiliência presentation ciaw...
dmarinojr
 
Frsnel's theory of diffraction.
Frsnel's theory of diffraction.Frsnel's theory of diffraction.
Frsnel's theory of diffraction.
Shivanand Angadi
 
BT631-14-X-Ray_Crystallography_Crystal_Symmetry
BT631-14-X-Ray_Crystallography_Crystal_SymmetryBT631-14-X-Ray_Crystallography_Crystal_Symmetry
BT631-14-X-Ray_Crystallography_Crystal_Symmetry
Rajesh G
 
Causal Inference and Direct Effects
Causal Inference and Direct EffectsCausal Inference and Direct Effects
Causal Inference and Direct Effects
jouffe
 
Relations in Discrete Math
Relations in Discrete MathRelations in Discrete Math
Relations in Discrete Math
Pearl Rose Cajenta
 
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...
SONU KUMAR
 
Applications of parabola
Applications of parabolaApplications of parabola
Applications of parabola
Nihaad Mohammed
 
Conic section Maths Class 11
Conic section Maths Class 11Conic section Maths Class 11
Conic section Maths Class 11
DevangSPSingh
 
Cylindrical and spherical coordinates shalini
Cylindrical and spherical coordinates shaliniCylindrical and spherical coordinates shalini
Cylindrical and spherical coordinates shalini
shalini singh
 
Conic Section
Conic SectionConic Section
Conic Section
Ashams kurian
 
Ellipse more properties
Ellipse more propertiesEllipse more properties
Ellipse more properties
rey castro
 
Parabola complete
Parabola completeParabola complete
Parabola complete
MATOME PETER
 
Atwoods Machine Slides.pdf
Atwoods Machine Slides.pdfAtwoods Machine Slides.pdf
Atwoods Machine Slides.pdf
phil239956
 
Black body radiations
Black body radiationsBlack body radiations
Black body radiations
ssuser260f8c
 
Pyrimidine
PyrimidinePyrimidine
Pyrimidine
Dr. Krishna Swamy. G
 
Parabola
ParabolaParabola
Parabola
itutor
 
Steroids, testosterone and progesterone
Steroids,  testosterone and progesteroneSteroids,  testosterone and progesterone
Steroids, testosterone and progesterone
Rudresh H M
 
Conic Sections- Circle, Parabola, Ellipse, Hyperbola
Conic Sections- Circle, Parabola, Ellipse, HyperbolaConic Sections- Circle, Parabola, Ellipse, Hyperbola
Conic Sections- Circle, Parabola, Ellipse, Hyperbola
Naman Kumar
 
Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...
Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...
Wolff kishner reduction, Organic and heterocyclic chemistry, As per PCI sylll...
Akhil Nagar
 
Medindo a robustez de uma rede com o fator de resiliência presentation ciaw...
Medindo a robustez de uma rede com o fator de resiliência   presentation ciaw...Medindo a robustez de uma rede com o fator de resiliência   presentation ciaw...
Medindo a robustez de uma rede com o fator de resiliência presentation ciaw...
dmarinojr
 
Frsnel's theory of diffraction.
Frsnel's theory of diffraction.Frsnel's theory of diffraction.
Frsnel's theory of diffraction.
Shivanand Angadi
 
BT631-14-X-Ray_Crystallography_Crystal_Symmetry
BT631-14-X-Ray_Crystallography_Crystal_SymmetryBT631-14-X-Ray_Crystallography_Crystal_Symmetry
BT631-14-X-Ray_Crystallography_Crystal_Symmetry
Rajesh G
 
Causal Inference and Direct Effects
Causal Inference and Direct EffectsCausal Inference and Direct Effects
Causal Inference and Direct Effects
jouffe
 
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...
GROUP, SUBGROUP, ABELIAN GROUP, NORMAL SUBGROUP, CONJUGATE NUMBER,NORMALIZER ...
SONU KUMAR
 
Applications of parabola
Applications of parabolaApplications of parabola
Applications of parabola
Nihaad Mohammed
 
Conic section Maths Class 11
Conic section Maths Class 11Conic section Maths Class 11
Conic section Maths Class 11
DevangSPSingh
 
Cylindrical and spherical coordinates shalini
Cylindrical and spherical coordinates shaliniCylindrical and spherical coordinates shalini
Cylindrical and spherical coordinates shalini
shalini singh
 
Ellipse more properties
Ellipse more propertiesEllipse more properties
Ellipse more properties
rey castro
 
Atwoods Machine Slides.pdf
Atwoods Machine Slides.pdfAtwoods Machine Slides.pdf
Atwoods Machine Slides.pdf
phil239956
 
Black body radiations
Black body radiationsBlack body radiations
Black body radiations
ssuser260f8c
 
Parabola
ParabolaParabola
Parabola
itutor
 
Steroids, testosterone and progesterone
Steroids,  testosterone and progesteroneSteroids,  testosterone and progesterone
Steroids, testosterone and progesterone
Rudresh H M
 

Similar to Detailed concept of function in c programming (20)

Function C programming
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna
 
unit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfunit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdf
JAVVAJI VENKATA RAO
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
Venkatesh Goud
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
vekariyakashyap
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
SangeetaBorde3
 
Function in c
Function in cFunction in c
Function in c
Raj Tandukar
 
Function in c
Function in cFunction in c
Function in c
CGC Technical campus,Mohali
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
KarthikSivagnanam2
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
Sampath Kumar
 
Functions in c
Functions in cFunctions in c
Functions in c
kalavathisugan
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
JVenkateshGoud
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
Rhishav Poudyal
 
Unit 4.pdf
Unit 4.pdfUnit 4.pdf
Unit 4.pdf
thenmozhip8
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
kushwahashivam413
 
USER DEFINED FUNCTIONS IN C.pdf
USER DEFINED FUNCTIONS IN C.pdfUSER DEFINED FUNCTIONS IN C.pdf
USER DEFINED FUNCTIONS IN C.pdf
BoomBoomers
 
C function
C functionC function
C function
thirumalaikumar3
 
c-Functions power point presentation on c functions
c-Functions power point presentation on c functionsc-Functions power point presentation on c functions
c-Functions power point presentation on c functions
10300PEDDIKISHOR
 
Function in c
Function in cFunction in c
Function in c
savitamhaske
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
ArshiniGubbala3
 
UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptx
NagasaiT
 
Ad

More from anjanasharma77573 (20)

In- Built Math function in java script..
In- Built Math function in java script..In- Built Math function in java script..
In- Built Math function in java script..
anjanasharma77573
 
In Built Math functions in java script..
In Built Math functions in java script..In Built Math functions in java script..
In Built Math functions in java script..
anjanasharma77573
 
What is tidyverse in R languages and different packages
What is tidyverse in R languages and different packagesWhat is tidyverse in R languages and different packages
What is tidyverse in R languages and different packages
anjanasharma77573
 
basic of data science and big data......
basic of data science and big data......basic of data science and big data......
basic of data science and big data......
anjanasharma77573
 
What is big data and 5'v of big data....
What is big data and 5'v of big data....What is big data and 5'v of big data....
What is big data and 5'v of big data....
anjanasharma77573
 
Basic of data and different type of data
Basic of data and different type of dataBasic of data and different type of data
Basic of data and different type of data
anjanasharma77573
 
What is Big Data , 5'v of BIG DATA and Challenges
What is Big Data , 5'v of BIG DATA and ChallengesWhat is Big Data , 5'v of BIG DATA and Challenges
What is Big Data , 5'v of BIG DATA and Challenges
anjanasharma77573
 
Basic of data science, and type of data.
Basic of data science, and type of data.Basic of data science, and type of data.
Basic of data science, and type of data.
anjanasharma77573
 
Role of Infogram, power bi and google charts
Role of Infogram, power bi and google chartsRole of Infogram, power bi and google charts
Role of Infogram, power bi and google charts
anjanasharma77573
 
DATA VISUALIZATION TOOLS e.g Power bi..
DATA VISUALIZATION TOOLS e.g  Power bi..DATA VISUALIZATION TOOLS e.g  Power bi..
DATA VISUALIZATION TOOLS e.g Power bi..
anjanasharma77573
 
type of vector data in vectors and geometries
type of vector data in vectors and geometriestype of vector data in vectors and geometries
type of vector data in vectors and geometries
anjanasharma77573
 
Introduction to vectors and geometry - ..
Introduction to vectors and geometry - ..Introduction to vectors and geometry - ..
Introduction to vectors and geometry - ..
anjanasharma77573
 
type of vector data in vectors and geometry
type of vector data in vectors and geometrytype of vector data in vectors and geometry
type of vector data in vectors and geometry
anjanasharma77573
 
Introduction to vectors and geometry -....
Introduction to vectors and geometry -....Introduction to vectors and geometry -....
Introduction to vectors and geometry -....
anjanasharma77573
 
basic of SQL constraints in database management system
basic of SQL constraints in database management systembasic of SQL constraints in database management system
basic of SQL constraints in database management system
anjanasharma77573
 
SQL subqueries in database management system
SQL subqueries in database management systemSQL subqueries in database management system
SQL subqueries in database management system
anjanasharma77573
 
practices of C programming function concepts
practices of C programming function conceptspractices of C programming function concepts
practices of C programming function concepts
anjanasharma77573
 
Practice of c PROGRAMMING logics and concepts
Practice of c PROGRAMMING logics and conceptsPractice of c PROGRAMMING logics and concepts
Practice of c PROGRAMMING logics and concepts
anjanasharma77573
 
programming concepts with c ++..........
programming concepts with c ++..........programming concepts with c ++..........
programming concepts with c ++..........
anjanasharma77573
 
basic of c programming practicals.......
basic of c programming practicals.......basic of c programming practicals.......
basic of c programming practicals.......
anjanasharma77573
 
In- Built Math function in java script..
In- Built Math function in java script..In- Built Math function in java script..
In- Built Math function in java script..
anjanasharma77573
 
In Built Math functions in java script..
In Built Math functions in java script..In Built Math functions in java script..
In Built Math functions in java script..
anjanasharma77573
 
What is tidyverse in R languages and different packages
What is tidyverse in R languages and different packagesWhat is tidyverse in R languages and different packages
What is tidyverse in R languages and different packages
anjanasharma77573
 
basic of data science and big data......
basic of data science and big data......basic of data science and big data......
basic of data science and big data......
anjanasharma77573
 
What is big data and 5'v of big data....
What is big data and 5'v of big data....What is big data and 5'v of big data....
What is big data and 5'v of big data....
anjanasharma77573
 
Basic of data and different type of data
Basic of data and different type of dataBasic of data and different type of data
Basic of data and different type of data
anjanasharma77573
 
What is Big Data , 5'v of BIG DATA and Challenges
What is Big Data , 5'v of BIG DATA and ChallengesWhat is Big Data , 5'v of BIG DATA and Challenges
What is Big Data , 5'v of BIG DATA and Challenges
anjanasharma77573
 
Basic of data science, and type of data.
Basic of data science, and type of data.Basic of data science, and type of data.
Basic of data science, and type of data.
anjanasharma77573
 
Role of Infogram, power bi and google charts
Role of Infogram, power bi and google chartsRole of Infogram, power bi and google charts
Role of Infogram, power bi and google charts
anjanasharma77573
 
DATA VISUALIZATION TOOLS e.g Power bi..
DATA VISUALIZATION TOOLS e.g  Power bi..DATA VISUALIZATION TOOLS e.g  Power bi..
DATA VISUALIZATION TOOLS e.g Power bi..
anjanasharma77573
 
type of vector data in vectors and geometries
type of vector data in vectors and geometriestype of vector data in vectors and geometries
type of vector data in vectors and geometries
anjanasharma77573
 
Introduction to vectors and geometry - ..
Introduction to vectors and geometry - ..Introduction to vectors and geometry - ..
Introduction to vectors and geometry - ..
anjanasharma77573
 
type of vector data in vectors and geometry
type of vector data in vectors and geometrytype of vector data in vectors and geometry
type of vector data in vectors and geometry
anjanasharma77573
 
Introduction to vectors and geometry -....
Introduction to vectors and geometry -....Introduction to vectors and geometry -....
Introduction to vectors and geometry -....
anjanasharma77573
 
basic of SQL constraints in database management system
basic of SQL constraints in database management systembasic of SQL constraints in database management system
basic of SQL constraints in database management system
anjanasharma77573
 
SQL subqueries in database management system
SQL subqueries in database management systemSQL subqueries in database management system
SQL subqueries in database management system
anjanasharma77573
 
practices of C programming function concepts
practices of C programming function conceptspractices of C programming function concepts
practices of C programming function concepts
anjanasharma77573
 
Practice of c PROGRAMMING logics and concepts
Practice of c PROGRAMMING logics and conceptsPractice of c PROGRAMMING logics and concepts
Practice of c PROGRAMMING logics and concepts
anjanasharma77573
 
programming concepts with c ++..........
programming concepts with c ++..........programming concepts with c ++..........
programming concepts with c ++..........
anjanasharma77573
 
basic of c programming practicals.......
basic of c programming practicals.......basic of c programming practicals.......
basic of c programming practicals.......
anjanasharma77573
 
Ad

Recently uploaded (20)

TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 

Detailed concept of function in c programming

  • 2. WHAT IS C FUNCTION?  A large C program is divided into basic building blocks called C function.  C function contains set of instructions enclosed by “{ }” which performs specific operation in a C program.  Every C program has at least one function, which is main().
  • 3. WHAT IS C FUNCTION?  A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.  The C standard library provides numerous built-in functions that your program can call. For example, strcat() to concatenate two strings,  A function can also be referred as a method or a sub-routine or a procedure, etc.
  • 4. USES OF C FUNCTIONS  C functions are used to avoid rewriting same logic/code again and again in a program.  There is no limit in calling C functions to make use of same functionality wherever required.  A large C program can easily be tracked when it is divided into functions.  The core concept of C functions are, re-usability, dividing a big task into small pieces to achieve the functionality and to improve understandability of very large C programs.
  • 5. Function declaration: 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 Example return_type function_name (argument list);
  • 7. 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). A C function is generally defined and declared in a single step because the function definition always starts with the function declaration so we do not need to declare it explicitly. The below example serves as both a function definition and a declaration. return_type function_name (arguments/parameter list) { Body of function; }
  • 9. 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. • The parameter list must not differ in function calling and function declaration. We must pass the same number of functions as it is declared in the function declaration. Syntax function_name (arguments/parameter list);
  • 11.  Function definition: return_type function_name (arguments list) { Body of function; }  Function call: function_name (arguments list);  Function declaration: return_type function_name (argument list);
  • 12. FUNCTION DECLARATION, FUNCTION CALL AND FUNCTION DEFINITION  There are 3 aspects in each C function. They are:  Function declaration or prototype – This informs compiler about the function name, function parameters and return value’s data type.  Function call – This calls the actual function  Function definition – This contains all the statements to be executed.
  • 15. #include <stdio.h> // Function declaration (prototype) int add(int a, int b); int main() { int num1 = 5; int num2 = 7; int result; // Function call result = add(num1, num2); printf("The sum is: %dn", result); return 0; } // Function definition int add(int a, int b) { return a + b; }
  • 16. #include<stdio.h> int square ( int ); // function prototype, also called function declaration int main( ) { int m, n ; printf ( "nEnter some number for finding square n"); scanf ( "%d", &m ) ; n = square (m) ; // function call printf ("nSquare of the given number %d is %d",m,n ); } int square ( int x ) // function definition { int p ; p = x * x ; return p; }
  • 17. TYPES OF FUNCTIONS There are two types of functions in C programming: Library Functions: are the functions which are declared in the C header files such as scanf(), printf(), gets(), puts(), pow() etc. User-defined functions: are the functions which are created by the C programmer, so that he/she can use it many times. It reduces the complexity of a big program and optimizes the code.
  • 18. HOW TO CALL C FUNCTIONS IN A PROGRAM?  There are two ways that a C function can be called from a program. They are:  Call by value  Call by reference Types of function parameters:  Actual parameter – This is the argument which is used in function call.  Formal parameter – This is the argument which is used in function definition
  • 19. CALL BY VALUE  In call by value method, the copy of the variable is passed to the function as parameter.  The value of the actual parameter can not be modified by formal parameter.  Different Memory is allocated for both actual and formal parameters. Because, value of actual parameter is copied to formal parameter. Note:
  • 20. #include<stdio.h> void swap(int a, int b); // function prototype, also called function declaration void main() { int m = 22, n = 44; printf(" values before swap m = %d n and n = %d", m, n); swap(m, n); //call by value printf(" nvalues after swap m = %dn and n = %d", m, n); getch(); } void swap(int m, int n) { int tmp; tmp = m; m = n; n = tmp; printf(" nvalues after swap m = %dn and n = %d", m, n); }
  • 21. CALL BY REFERENCE  In call by reference method, the address of the variable is passed to the function as parameter.  The value of the actual parameter can be modified by formal parameter.  Same memory is used for both actual and formal parameters since only address is used by both parameters.
  • 22. #include<stdio.h> void swap(int *, int *); // function prototype, also called function declaration void main() { int m = 22, n = 44; printf("values before swap m = %d n and n = %d",m,n); swap(&m, &n); // calling swap function by reference printf("n values after swap m = %d n and n = %d", m, n); getch(); } void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; printf("n Swap function values after swap a = %d nand b = %d", *a, *b); }
  • 23. C - SCOPE RULES  A scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable it cannot be accessed.  There are three places where variables can be declared in C programming language −  Inside a function or a block which is called local variables.  Outside of all functions which is called global variables.  In the definition of function parameters which are called formal parameters.
  • 24. LOCAL VARIABLES  Variables that are declared inside a function or block are called local variables.  They can be used only by statements that are inside that function or block of code.  Local variables are not known to functions outside their own.
  • 25. We can define the User defined functions in multiple ways  Function with no argument and no Return value  Function with no argument and with Return value  Function with argument and No Return value  Function with argument and Return value
  • 26. Function with No argument and No Return value In this method, We won’t pass any arguments to the function while defining, declaring or calling the function. This type of functions will not return any value when we call the function from main() or any sub function. When we are not expecting any return value but, we need some statements to be printed as output then, this type of functions are very useful. #include<stdio.h> void Addition(); // Function Declaration int main() { printf("n ............. n"); Addition(); // Function call } void Addition() { int Sum, a = 10, b = 20; Sum = a + b; printf("n Sum of a = %d and b = %d is = %d", a, b, Sum); }
  • 27. Function with no argument and with Return value n this method, We won’t pass any arguments to the function while defining, declaring or calling the function. This type of functions will return some value when we call the function from main() or any sub function. Data Type of the return value will depend upon the return type of function declaration. For instance, if the return type is int then return value will be int. #include<stdio.h> int Multiplication(); int main() { int Multi; Multi = Multiplication(); printf("n Multiplication of a and b is = %d n", Multi ); return 0; } int Multiplication() { int Multi, a = 20, b = 40; Multi = a * b; return Multi; }
  • 28. Function with argument and No Return value This method allows us to pass the arguments to the function while calling the function. But, This type of functions will not return any value when we call the function from main () or any sub function. #include<stdio.h> int Addition(int, int); Int main() { int a, b; printf("n Please Enter two integer values n"); scanf("%d %d",&a, &b); Addition(a, b); } int Addition(int a, int b) { int Sum; Sum = a + b; printf("n Additiontion of %d and %d is = %d n", a, b, Sum); }
  • 29. Function with argument and Return value This method allows us to pass the arguments to the function while calling the function. This type of functions will return some value when we call the function from main () or any sub function. Data Type of the return value will depend upon the return type of function declaration. For instance, if the return type is int then return value will be int. #include<stdio.h> int Multiplication(int, int); int main() { int a, b, Multi; printf("n Please Enter two integer values n"); scanf("%d %d",&a, &b); Multi = Multiplication(a, b); printf("n Multiplication of %d and %d is = %d n", a, b, Multi); return 0; } int Multiplication(int a, int b) { int Multi; Multi = a * b; return Multi; }
  • 30. Recursion A function that calls itself is known as a recursive function.And, this technique is known as recursion.  In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function. Syntax: void recursion() { recursion(); /* function calls itself */ } int main() { recursion(); }
  • 31. Factorial using Recursion #include <stdio.h> int fact (int); int main() { int n,f; printf("Enter the number whose f actorial you want to calculate?"); scanf("%d",&n); f = fact(n); printf("factorial = %d",f); } int fact(int n) { if (n==0) { return 0; } else if ( n == 1) { return 1; } else { return n*fact(n-1); } }
  • 33. Advantages & Disadvantages of Recursion Advantage Recursion makes program elegant and cleaner.All algorithms can be defined recursively which makes it easier to visualize and prove. Reduce unnecessary calling of function. Disadvantage If the speed of the program is vital then, you should avoid using recursion. Recursions use more memory and are generally slow. Instead, you can use loop. programmers need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop. Recursive solution is always logical and it is very difficult to trace.(debug and understand). In recursive we must have an if statement somewhere to force the function to return without the recursive call being executed, otherwise the function will never return. Recursion takes a lot of stack space, usually not considerable when the program is small and running on a PC. Recursion uses more processor time
  • 34. • C Standard library functions or simply C Library functions are inbuilt functions in C programming. • The prototype and data definitions of the functions are present in their respective header files, and must be included in your program to access them. Advantages of using standard library functions: 1. They work These functions have gone through multiple rigorous testing and are easy to use. 2. The functions are optimized for performance In the process, they are able to create the most efficient code optimized for maximum performance. 3. It saves considerable development time Since the general functions like printing to a screen, calculating the square root, and many more are already written. You shouldn't worry about creating them once again. It saves valuable time and your code may not always be the most efficient. 3. The functions are portable With ever changing real world needs, your application is expected to work every time, everywhere. And, these library functions help you in that they do the same thing on every computer. This saves time, effort and makes your program portable. Library functions
  • 35. #include <stdio.h> #include <math.h> int main() { float num, root; printf("Enter a number: "); scanf("%f", &num); // Computes the square root of num and stores in root. root = sqrt(num); printf("Square root of %.2f = %.2f", num, root); return 0; }
  • 36. Some more examples of Library functions:
  • 37. #include <stdio.h> #include <math.h> #define PI 3.141592654 int main() { double num = 3.0; double result; result = atan(num); printf("Inverse of tan(%.2f) = %.2f in radians", num, result); return 0; }
  • 38. #include <stdio.h> #include <math.h> #define PI 3.141592654 int main() { double num = 0.0; double result; result = acos(num); printf("Inverse of tan(%.2f) = %.2f in radians", num, result);
  • 39. #include <stdio.h> #include <math.h> #define PI 3.141592654 int main() { double num = 2.0; double result; result = cos(num); printf("Inverse of tan(%.2f) = %.2f in radians", num, result); return 0; }
  翻译: