# Cognizant Procedure Functions & Scope Questions & Answers

Question 1 Time: 00:00:00
The default parameter passing mechanism is call by value

call by value

call by reference

call by reference

call by value result

call by value result

None of these.

None of these.

Once you attempt the question then PrepInsta explanation will be displayed. Start

Question 2 Time: 00:00:00
```Determine output:
main()
{
int i = 5;
printf("%d%d%d%d%d", i++, i--, ++i, --i, i);
}

``` 5454

5454

45445

45445

54554

54554

45545

45545

Once you attempt the question then PrepInsta explanation will be displayed.

When passing an argument in a function all the arguments and local variables are stored in a memory called stack. After the function being called stack have to be deleted either by called function or by calling function. But in the standard convention, it deleted by the called function. we have two choices: 1) From left to right. 2)From right to left. This depends upon the calling convention, which is right to left.

The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result. See the picture below Function mcq solution image Start

Question 3 Time: 00:00:00
What will be printed when this program is executed?
```int f(int x)
{
if(x <= 4)
return x;
return f(--x);
}
void main()
{
printf("%d ", f(7));
}``` 4 5 6 7

4 5 6 7

1 2 3 4

1 2 3 4

4

4

Syntax error

Syntax error

Runtime error

Runtime error

Once you attempt the question then PrepInsta explanation will be displayed. Start

Question 4 Time: 00:00:00
Which of the following function calculates the square of 'x' in C? sqr(x)

sqr(x)

power(x, 2)

power(x, 2)

power(2, x)

power(2, x)

pow(x, 2)

pow(x, 2)

pow(2, x)

pow(2, x)

Once you attempt the question then PrepInsta explanation will be displayed. Start

Question 5 Time: 00:00:00
char* myfunc(char *ptr)
{
ptr+=3;
return(ptr);
}

void main()
{
char *x, *y;
x = "PrepInsta";
y = myfunc(x);
printf("y=%s", y);
}
What will be printed when the sample code above is executed? y=PrepInsta

y=PrepInsta

y=pInsta

y=pInsta

y=Insta

y=Insta

y=nsta

y=nsta

y=epInsta

y=epInsta

Once you attempt the question then PrepInsta explanation will be displayed. Start

Question 6 Time: 00:00:00
```#include <stdio.h>
extern int var;
int main()
{
var = 10;
printf("%d ", var);
return 0;
}``` 20

20

compiler error

compiler error

Once you attempt the question then PrepInsta explanation will be displayed. 