Program to delete duplicates from a link list

return type of function

return type of function:- 

(3). With argument- without return:-

                                                                 In this type,  function  takes argument but does not  return any value.
#include<stdio.h>




void sum(int,int); 
int main()
{
     int a,b;
     printf("Enter the value of a and b");
     scanf("%d%d",&a,&b);
     sum(a,b);   // function calling 
     return 0;


}
// End of main function 
// function definition of sum




void sum(int x,int y)
//where x and y are formal argument 
{
    int z;
    z=x+y;
    printf("sum of a and b is %d",z);
}

 

output:-

Enter the value of a and b
10 5
sum is 15
(4). without argument- without return:-
                                                                     In this type,  function does not  takes any argument and does not return any value.
#include<stdio.h>
// Global declaration of sum
void sum(void); 
int main()
{
    
     sum();   // function calling 
     return 0;


}
// End of main function 
// function definition of sum




void sum(void)
//where x and y are formal argument 
{
    int x,y,z;
    printf("Enter the value of x and y");
    scanf("%d%d",&x,&y);
    z=x+y;
    printf("sum of %d and %d is %d",x,y,z);
}

output:-

Enter the value of x and y
10 5
sum of 10 and 5 is 15

Practice question based on return type of function:-

  • 1) Write a function to calculate factorial of a number.(Takes Something, Returns Something).

  • 2) Write a function to calculate area of a circle.(Takes Something, Returns Something)

 

Recommended Post:

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

 

Leave a Reply

Your email address will not be published.