Computer Science, asked by sakshi9294, 9 months ago

design a method containing suitable statement of your choice that returns an integer




answer fast ..I have increased the point​

Answers

Answered by jiya91729
17

Answer:

Prerequisite : Functions in C/C++

A function in C can be called either with arguments or without arguments. These function may or may not return values to the calling functions. All C functions can be called either with arguments or without arguments in a C program. Also, they may or may not return any values. Hence the function prototype of a function in C is as below:

There are following categories:

Function with no argument and no return value : When a function has no arguments, it does not receive any data from the calling function. Similarly when it does not return a value, the calling function does not receive any data from the called function.

Syntax :

Function declaration : void function(); Function call : function(); Function definition : void function() { statements; }

// C code for  function with no

//  arguments and no return value

  

#include <stdio.h>

void value(void);

void main()

{

    value();

}

void value(void)

{

    int year = 1, period = 5, amount = 5000, inrate = 0.12;

    float sum;

    sum = amount;

    while (year <= period) {

        sum = sum * (1 + inrate);

        year = year + 1;

    }

    printf(" The total amount is %f:", sum);

}

Output:

The total amount is 5000.000000

Function with arguments but no return value : When a function has arguments, it receive any data from the calling function but it returns no values.

Syntax :

Function declaration : void function ( int ); Function call : function( x ); Function definition: void function( int x ) { statements; }

// C code for function 

// with argument but no return value

#include <stdio.h>

  

void function(int, int[], char[]);

int main()

{

    

Answered by Anonymous
0

Answer: A function in C can be called either with arguments or without arguments. These function may or may not return values to the calling functions. All C functions can be called either with arguments or without arguments in a C program. Also, they may or may not return any values. Hence the function prototype of a function in C.

Explanation:

Similar questions