STRUCTURES AND UNIONS IN C PROGRAMMING LANGUAGE

MahalakshmiS100 4 views 21 slides Oct 27, 2025
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

STRUCTURES AND UNIONS


Slide Content

FUNCTIONS POINTERS AND STRUCTURES UNIT-IV

FUNCTIONS IN C PROGRAM There are three aspects of a C function. Function declaration :  A function must be declared globally in a c program to tell the compiler about the function name, function parameters, and return type. Function call :  Function can be called from anywhere in the program. 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. Function definition :  It contains the actual statements which are to be executed. It is the most important aspect to which the control comes when the function is called. Here, we must notice that only one value can be returned from the function. Types of function There are two types of functions in C programming Built-in functions: These are functions that are already defined in the C library and can be directly called in the program. Examples include the math and string functions mentioned previously. User-defined functions: These are functions that are defined by the user (programmer) and can be used to perform specific tasks in the program. Return Type Non-Return Type          A function in C has the following syntax:             return_type function_name ( parameter1, parameter2, ... )            {                  // body of Statement ;            }

  Return Type : Int :  Int as the return type if the function returns value. Void :  Void as the return type if the function returns no value.   Parameter list : It is a list of arguments  ( data_type variable_name )  that will be used in the function. Different aspects of function calling function without arguments and without return value function without arguments and with return value function with arguments and without return value function with arguments and with return value

No Return Without Argument Function in C In C programming, a function that does not take any arguments and does not return a value is called a void function. The syntax for defining a void function is as follows:          Syntax:             return_type function_name ( parameter1, parameter2, ... )            {                  // body of Statement ;            }          Example :            void function_name ( )            {                  // body of Statement ;            } Here, the 'void' keyword is used as the return type to indicate that the function does not return any value. A void function can be called in the same way as other functions, by simply using the function name followed by empty parentheses:              function_name ( );

#include<stdio.h> //No Return Without Argument Function in C //Function Declaration void add(); int main() { //Function Calling add(); return 0; } //Function Definition void add() { int a,b,c ; printf (" \ n Enter The Value of A & B :"); scanf ("% d%d ",& a,&b ); c= a+b ; printf (" \ n Total : % d",c ); }

//No Return With Argument Function in C #include<stdio.h> //Function Declaration void add( int,int ); int main() { int a,b ; printf (" \ n Enter The Value of A & B : ")l scanf ("% d%d ",& a,&b ); //Function Calling add( a,b ); // Actual Parameters return 0; } //Function Definition void add(int x,int y) //Formal Parameters { int c; c= x+y ; printf (" \ n Total : % d",c ); }  

//Return Without Argument Function in C #include<stdio.h>   int add();   int main() { int a; a=add(); printf (" \ n Total : % d",a ); return 0; }   int add() { int a,b ; printf (" \ n Enter The Value of A & B : "); scanf ("% d%d ",& a,&b ); return a+b ; }  

//Return With Argument Function in C #include<stdio.h> int add( int,int ); int main() { int a,b ; printf (" \ n Enter The Value of A & B : "); scanf ("% d%d ",& a,&b ); a=add( a,b ); printf (" \ n Total : % d",a ); return 0; }   int add(int x,int y) { return x+y ; }  
Tags