3i Infotech Papers: Sample Questions 1083 - 1085 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 1083

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What does static variable mean?

Explanation

  • Static variable is available throughout the lifetime.

  • At the time of starting the program execution, static variables allocations take place.

  • They cover a scenario where one variable is to used by all the functions, or the variable needs to survive across function invocations.

  • Variables are declared static in a C program.

  • For variables declared in the function, the value of the variable is persisted between successive calls to functions- access qualifier limits the scope but causes the variable to exist for the lifetime of the program.

  • Function static variable is thus not seen outside the function in which it is declared but remains until the program terminates.

  • The value of variable will remain and may be seen even after calls to a function.

Question number: 1084

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Write a macro for swapping integers.

Explanation

  1. #include<iostream.h>
  2. #include<conio.h>
  3. #define SWAP(a,b) {int temptemp=aa=bb=temp;}
  4. void main()
  5. {
  6.     clrscr();
  7.     int x,y;
  8.     cout<<“Enter two numbers:”;
  9.     cin>>x>>y;
  10.     cout<<“x=”<<x<<” y=”<<y;
  11.     SWAP(x,y);
  12.     cout<<“nx=”<<x<<” y=”<<y;
  13.     getch();
  14. }

Question number: 1085

» Basic CS » Data Structures

Essay Question▾

Describe in Detail

What is recursion?

Explanation

Understanding of recursion in c programming.

Understanding of Recursion in C Programming.

Understanding of recursion in c programming.

  • Recursion is the process of repeating items in a self-similar way.

  • It happens when a function calls itself- called a recursive call of the function.

  • Thus recursion is the process where one of the instructions is to “repeat the process”.

  • Similar to loop because it repeats the same code, and in some ways it is similar to looping.

  • Programmatically recursion expresses ideas where result of the recursive call is necessary to complete the task.

Advantages of Recursion:

  • Function calling related information is maintained by recursion.

  • Stack evaluation will take place by using recursion.

  • Fix prefix, post-fix notation will be evaluated by recursion.

Disadvantages of recursion:

  • Slow process due to stack overlapping.

  • Recursive program can create stack overflow.

  • Functions can create.