🔥🔥Function and Recursion 🔥🔥
🔥🔥🔥🔥 Function 🔥🔥🔥🔥
Function is the block of codes which we can use multiple time and used to minimize the readability of code.
#include <stdio.h>
void nameDisplay();
int main()
{
printf("First Function nameDisplay is initializing\n");
nameDisplay();
printf("First Function nameDisplay is Completed\n");
return 0;
}
void nameDisplay()
{
printf("I am the nameDisplay Function\n");
}
syntax and implementation of function
Function Prototype
function call
Function definition
#include <stdio.h>
void goodmorning(); //--->function prototype :- Where all the function are set to that dont have any arguments and not what it returns or not;
void goodafternoon(); //--->function prototype :- Where all the function are set to that dont have any arguments and not what it returns or not;
void goodnight(); //--->function prototype :- Where all the function are set to that dont have any arguments and not what it returns or not;
int main()
{
goodmorning(); //---> function calling :- In this function are call to executed in program;
goodafternoon(); //---> function calling :- In this function are call to executed in program;
goodnight(); //---> function calling :- In this function are call to executed in program;
return 0;
}
void goodmorning()
{
printf("Good Morning Nick\n"); //---> In this it is called function definition where the funcrion code is writen and the concept and logic are written to be executed
// goodafternoon(); //we can call function inside the function also.
// goodnight();
}
void goodafternoon()
{
printf("Good afternoon Nick\n"); //---> In this it is called function definition where the funcrion code is writen and the concept and logic are written to be executed
}
void goodnight()
{
printf("Good Night Nick\n"); //---> In this it is called function definition where the funcrion code is writen and the concept and logic are written to be executed
}
v
#include <stdio.h>
#include <math.h>
int main()
{
int a, area;
printf("Enter the Value of side:");
scanf("%d", &a);
// area = pow(a, 2);
printf("Area Of Square: %f\n", pow(a, 2)); //pow---> always return double value
// printf("Area Of Square: %f\n", area);
return 0;
}
v
#include <stdio.h>
float temp(float x);
int main()
{
float c;
printf("Enter the value of Celcius to get in farenhite:");
scanf("%f", &c);
printf("Value of %fC to Farenheit is: %.2f\n", c, temp(c));
return 0;
}
float temp(float x)
{
float f;
f = (float)(x * 9 / 5) + 32;
return f;
}
v
v
v
v
v
v
v
v
v
Comments
Post a Comment