Computer Science, asked by souravparashar366, 2 months ago

What is Function ? How many types of it ? Explain with program.​

Answers

Answered by xXMrAkduXx
1

 \large\green{\textsf{✩ Verified Answer ✓ }}

A function is a process or a relation that associates each element x of a set X, the domain of the function, to a single element y of another set Y (possibly the same set), the codomain of the function. It is customarily denoted by letters such as f, g and h.

There can be 4 different types of user-defined functions, they are: Function with no arguments and no return value. Function with no arguments and a return value. Function with arguments and no return value.

 \bf\pink{\textsf{Answered By MrAkdu}}

Answered by aryansuts01
0

Answer:

A function of the return value only returns one result. A function is a generated type because the type of the data it returns determines its type. Arrays, pointers, enumeration types, structures, and groups are other related types.

Explanation:

A function is a segment of clean, reusable code that executes a single, connected operation. A higher level of code reuse and improved application modularity are provided via functions. Various functions like printf() and main have already been shown to you ().

Types of functions:

A function could fall under any of the following groups:

  1. functions that have no arguments and no output.
  2. functions without return values and with arguments.
  3. functions with return values & arguments.

Program:

#include<stdio.h>

void statement1();

void statement2();

void starline();

int main() {

statement1();

starline();

statement2();

starline();

return 0;

}

/*function to print a message*/

void statement1() {

printf("\n Sample subprogram output");

}

void statement2() {

printf("\n Sample subprogram output two");

}

void starline() {

int a;

for (a=1;a<40;a++)

printf("%c",'*');

printf("\n");

}

#SPJ3

Similar questions