Math, asked by pingku73, 1 year ago

What is function? Write a C program to find
of square of a number using function prototype.

Answers

Answered by tanwarkoshinder
2

A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions

how to declare a function?

A function declaration tells the compiler about a function name and how to call the function. The actual body of the function can be defined separately.

A function declaration has the following parts −

return_type function_name( parameter list );

For the above defined function max(), the function declaration is as follows −

int max(int num1, int num2);

Parameter names are not important in function declaration only their type is required, so the following is also a valid declaration −

int max(int, int);

Function declaration is required when you define a function in one source file and you call that function in another file. In such case, you should declare the function at the top of the file calling the function.

program for square of a number using functions :-

#include<stdio.h>

#include<conio.h>

int sqre(int);

void main()

{

int n,s;

clrscr();

printf(“Enter any number: “);

scanf(“%d”,&n);

s=sqre(n);

printf(“Square of given number is:%d”,s);

getch();

}

int sqre(int a)

{

return(a*a);

}


tanwarkoshinder: mark my ans brainliest if it helped.
Similar questions