Function Prototypes:
i. Function without arguments and without return type
ii. Function with arguments and without return type
iii. Function without arguments and with return type
iv. Function with arguments and with return type
o In this type no argument is passed through the function call and no output is return to main function
o The sub function will read the input values perform the operation and print the result in the same block
o Arguments are passed through the function call but output is not return to the main function
o In this type no argument is passed through the function call but output is return to the main function.
In this type arguments are passed through the function call and output is return to the main function
def add():
a=int(input("enter a"))
b=int(input("enter b"))
c=a+b
print(c)
add()
OUTPUT:
enter a 5
enter b 10
15
def add(a,b):
c=a+b
print(c)
a=int(input("enter a"))
b=int(input("enter b"))
add(a,b)
OUTPUT:
enter a 5
enter b 10
15
def add():
a=int(input("enter a"))
b=int(input("enter b"))
c=a+b
return c
c=add()
print(c)
OUTPUT:
enter a 5
enter b 10
15
def add(a,b):
c=a+b
return c
a=int(input("enter a"))
b=int(input("enter b"))
c=add(a,b)
print(c)
enter a 5
enter b 10
15
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.