Alpingi.com

Freshers Jobs | AMCAT | Fresherworld | JEE | NEET | GATE & CAT

AMCAT coupon code --> ALP50 | Freshersworld Discount Code --> AFF1451AGI
TechMario UpdatesAMCAT Discount Code (ALP50) - get flat off TechMario UpdatesFreshersworld Coupon Code (AFF1451AGI) - - get flat 100 off

Download AMCAT Procedure functions and scope Sample Questions

AMCAT Computer Programming section: In general, AMCAT exam consists of 3 mandatory modules- Quantitative ability, Reasoning ability and English language. Besides these modules, there is Computer Programming section in the AMCAT test. This part is however optional and depends on the interest of the candidate to take up. But this section is relevant and definitely creates a different impression on the recruiter. Furthermore,we will discuss AMCAT Procedure functions and scope Sample Questions.

AMCAT Procedure functions and scope Sample Questions

AMCAT Procedure functions and scope Sample Questions

AMCAT Procedure functions and scope Sample Questions

In order to face AMCAT Computer Programming questions, it is very much essential to practice sample questions.
Hence, here we will share you an overview of procedure, functions and scope in programming language. We will also add practice questions file with answers.

About Procedure functions and scope in Computer Programming

In Computer Programming, there are rather, certain tasks that has to be done repetitively. For reducing the extra effort in coding,especially of writing the same code again and again, there is the concept of procedure and functions.

Procedure:

Procedure is significantly like a set of instructions to be executed in the program. It explicitly defines the flow of the code and the navigations. In other words, we can also say that its the process or procedure of breaking and dividing the whole flow into modules of code to complete the program.

Functions:

Function is a segment of code that has to be written once and can be used again and again by simply calling it. Furthermore, here the input can be passed to the function in the form of arguments.
Syntax-
Function(args)
Statements
End Function

Scope: In fact, Scope of inputs of a function can be defined significantly in two ways. In general, they are pass by value and pass by reference. Also, by default the scope of arguments in a function is passed by value. Check out the following example to understand more clearly.

Pass by value:
void swap(int x, int y)
{
int tmp = x;
x = y;
y = tmp;
}

int main(){

int m = 6;

int n = 10;

printf(“Before swapping (m,n) evaluate to: (%d,%d)\n”,m,n);

swap(m,n);

printf(“After swapping (m,n) evaluate to: (%d,%d)\n”,m,n); // m and n still equal to their original values

}

Pass by reference:

// Also the ampersand operator (&) states that both the input arguments to this function will actually be

references to the arguments used during function call

void swap(int& x, int& y){

int tmp = x;

x = y;

y = tmp;

}

int main() {

int m = 6;

int n = 10;

printf(“Before swapping (m,n) evaluate to: (%d,%d)\n”,m,n);

swap(m,n); // we now invoke the function on the two integer types

// in fact their corresponding reference types will be passed to the swap function

printf(“After swapping (m,n) evaluate to: (%d,%d)\n”,m,n); // Also m and n now have swapped their original values

}

Download AMCAT Procedure functions and scope Sample Questions

AMCAT Procedure functions and scope Sample Questions

Find out more questions on Computer Programming
Data types
Iteration, Recursion and Decision statements

Mock test on AMCAT Procedure functions and scope Sample Questions

Question 1
A function cannot be defined inside another function
A. True
B. False
Answer: Option A
Explanation: A function cannot be defined inside the another function, but a function can be called inside a another function.

Question 2
Functions cannot return more than one value at a time
A. True
B. False
Answer:
Option A
Explanation: True, A function cannot return more than one value at a time. Because after returning a value the control is given back to calling function.

Question 3
How many times the program will print “Alpingi” ?
#include<stdio.h>
int main(){
printf(“Alpingi”);
main();
return 0;
}
A. Infinite times
B. 32767 times
C. 65535 times
D. Till stack overflows
Answer:
Option D
Explanation: 
A call stack or function stack is explicitly used for several related purposes. But the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing. A stack overflow occurs when too much memory is used on the call stack.
Furthermore, function main() is called repeatedly and its return address is stored in the stack. In addition, after stack memory is full,it shows stack overflow error.

Mock questions

Question 4
The default parameter passing mechanism is 
A. call by value
B. call by reference
C. In general, call by value result
D. In fact, none of these.
Answer:
Option A

Question 5
Which of the following function explicitly calculates the square of ‘x’ in C?
A. sqr(x)
B. power(x, 2)
C. power(2, x)
D. pow(x, 2)
E. pow(2, x)
Answer: 
Option B

Explanation: Since, power(x, 2) is an inbuilt mathematical function to calculate power, therefore the correct answer is power(x,2).

In conclusion, hope this helps you to understand function and its scope in Computer programming.

Also, please comment below for any queries on AMCAT Procedure functions and scope Sample Questions.

Leave a Reply

Your email address will not be published.

alpingi © 2018