Which of the following is a complete function?
A.int funct();
B.int funct(int x) { return x=x+1; }
C.void funct(int) { printf(âHello"); }
D.void funct(x) { printf(âHello"); }
Answers
Answered by
20
Hope ur answer is
Option (B)
Hope it helps u
Option (B)
Hope it helps u
Answered by
0
Answer:
The correct answer to the given question is:
B) int funct(int x) { return x=x+1; }
Explanation:
Functions "Encapsulate" a task (they combine multiple commands into a single line of code). Most programming languages provide many built-in functions that would otherwise take many steps to complete, such as calculating the square root of a number. In general, we don't care how a function does what it does, only how it "does" it!
When a function is "called", the program "leaves" the current code and starts executing the first line inside the function.
Steps to write a function
- Understand the purpose of the function.
- Determine the data that goes into the function from the caller (as a parameter)!
- Define the data variables needed inside the function to achieve its purpose.
- Decide on the set of steps the program will use to achieve this goal. (Algorithm)
#SPJ2
Similar questions