Function and Recursion · Programming Languages · GATE CSE
Start PracticeMarks 1
GATE CSE 2024 Set 2
Consider the following C program. Assume parameters to a function are evaluated from right to left.
#include <studio.h>
int g(int p) { printf(...
GATE CSE 2024 Set 1
Consider the following C program:
#include <stdio.h>
void fX();
int main() {
fX();
return 0;}
void fX() {
char a;
if ((a = get...
GATE CSE 2023
The integer value printed by the ANSI-C program given below is ___________.
#include<stdio.h>
int funcp(){
static int x = 1;
x++ ;
...
GATE CSE 2021 Set 2
Consider the following ANSI C function:
int SomeFunction (int x, int y)
{
if ( (x == 1) I I (y == 1)) return 1;
if (x == y) return x;
if (x ...
GATE CSE 2019
Consider the following C program:
#include < stdio.h >
int jumble (int x, int y) {
x = 2 * x + y ;
...
GATE CSE 2018
Consider the following C program:
#include < stdio.h >
int counter = 0;
int calc (int a, int b) {
int c;
counter++;
if (b==3) return (...
GATE CSE 2015 Set 3
Consider the following C program segment.
#include < stdio.h >
int main()
{
char s1[7] = "1234", *p;
p = s1 + 2;
*p = ‘0’;
printf...
GATE CSE 2015 Set 2
Consider the following function written in the C programming language.
void foo(char *a){
if ( *a && *a != ' '){
foo(a+1);
putchar(...
GATE CSE 2012
What will be the output of the following C program segment?
Char inchar = 'A';
Switch ( inchar ) {
case 'A' : printf ("Choice A\ n") ;
case 'B' :
case...
GATE CSE 2005
Which one of the following are essential features of an object-oriented programming language?
i) Abstraction and encapsulation
ii) Strictly-typedness
...
GATE CSE 2005
An Abstract Data Type (ADT) is
GATE CSE 2003
Consider the following C function.
float f,(float x, int y) {
float p, s; int i;
for (s=1,p=1,i=1; i < y; i++) {
p *= x/i;
...
GATE CSE 2002
In the C language
Marks 2
GATE CSE 2024 Set 1
Consider the following C function definition.
int f(int x, int y) {
for (int i=0; i<y; i++) {
x=x+x+y;
}
return x;
}
Which o...
GATE CSE 2022
What is printed by the following ANSI C program?
#include <stdio.h>
int main(int argc, char *argv[ ]) {
int a[3][3][3] = {{1, 2, 3, 4,...
GATE CSE 2021 Set 2
Consider the following ANSI C program
#include <stdio.h>
int foo(int x, int y, int q)
{
if ((x <= 0 && (y <= 0))
return q;
i...
GATE CSE 2021 Set 1
Consider the following ANSI C program.
#include <stdio.h>
int main( ) {
int i, j, count;
count = 0;
i = 0;
for (j = -3; j = 0) && (i++))
...
GATE CSE 2021 Set 1
Consider the following ANSI C function:
int SimpleFunction (int y[], int n, int x)
{
int total = y[0], loopIndex;
for (loopIndex = 1; loopIndex &l...
GATE CSE 2020
Consider the following C functions.
int fun1 (int n) {
static int i = 0;
if (n > 0) {
++i;
fun1(n-1);
}
...
GATE CSE 2020
Consider the following C functions.
int tob(int b, int* arr) {
int i;
for (i=0; b>0; i++) {
if (b%2) arr[i] = 1;
el...
GATE CSE 2019
Consider the following C function.
void convert(int n){
if(n < 0)
printf("%d",n);
else {
convert(n/2);
printf(...
GATE CSE 2019
Consider the following C program :
#include<stdio.h>
int r()
{
static int num=7;
return num--;
}
int main()
{
fo...
GATE CSE 2018
Consider the following C code. Assume that unsigned long int type length is 64
bits.
unsigned long int fun(unsigned long int n){
unsigned long in...
GATE CSE 2015 Set 2
Consider the C program below.
#include < stdio.h >
int *A, stkTop;
int stkFunc(int opcode, int val)
{
static int size=0, stkTop=0;
swi...
GATE CSE 2012
Consider the program given below, in a block-structured pseudo-language with lexical
scoping and nesting of procedures permitted.
Program main;
Var ...
GATE CSE 2011
Consider the following recursive C function that takes two arguments:
unsigned int foo (unsigned int n, unsigned int r) {
if (n > 0) return((n % ...
GATE CSE 2011
Consider the following recursive C function that takes two arguments:
unsigned int foo (unsigned int n, unsigned int r) {
if (n > 0) return((n % ...
GATE CSE 2008
Choose the correct option to fill ? 1 and ? 2 so that the program below prints an
input string in reverse order. Assume that the input string is termi...
GATE CSE 2007
Consider the following C function:
int f(int n)
{
static int r = 0;
if(n <= 0) return 1;
if(n>3)
{
r = n;
return f(n-2)+2;...
GATE CSE 2005
Consider the following C program:
void foo (int n, int sum) {
int k = 0, j = 0;
if(n==0) return;
k=n%10; j = n /10;
sum = sum + k;
foo(j, su...
GATE CSE 2005
Consider the following C program:
double foo(double); /* Line 1 */
int main () {
double da, db;
//input da
db = foo(da);
}
double foo(double a){...
GATE CSE 2004
Consider the following C function:
int f(int n)
{
static int i = 1;
if(n>=5) return n;
n = n+1;
i++;
return f(n);
}
The value returned by f(1) is...
GATE CSE 2004
Consider the following C program
main ( )
{
int x, y, m, n;
scanf("%d %d", &x, &y);
/* Assume x > 0 and y > 0 */
m=x; n=y;
wh...
GATE CSE 2003
Consider the following class definitions in a hypothetical Object Oriented
language that supports inheritance and uses dynamic binding. The language
s...
GATE CSE 2002
Consider the following declaration of a two-dimensional array in C:
char a[100][100];
Assuming that the main memory is byte-addressable and that the a...
GATE CSE 2000
The value of j at the end of the execution of the following C program
int incr (int i)
{
static int count = 0;
count = count + i;
retur...
GATE CSE 1999
Consider the following C function definition
int Trial (int a, int b, int c)
{
if ((a > = b) && (c < b)) return b;
else if...
GATE CSE 1998
What is the result of the following program?
program side-effect (input, output);
var x, result: integer:
fucntion f (var x:integer):integer;
begin
...
GATE CSE 1998
What value would the following function return for the input x = 95?
Function fun (x:integer):integer;
Begin
If x > 100 then fun : x – 10
...
GATE CSE 1995
What is the value of X printed by the following program?
program COMPUTE (input, output);
var
X:integer;
procedure FIND (X:real);
begin
X:...
GATE CSE 1993
What does the following code do?
var a, b : integer;
begin
a:=a+b;
b:=a-b;
a:=a-b;
end;