Function: GATE CS Previous Year Questions

Function · Programming in C

68 questions · asked in 26 of 27 years (2000–2026)

MCQ 47 · NAT 211-mark 35 · 2-mark 33

2000Questions per year2026

Questions 56–60 of 68

Q56GATE 20051 markMCQ−0.33 if wrong
What does the following C-statement declare?
int ( * f) (int * ) ; 

Q57GATE 20041 markMCQ−0.33 if wrong
Consider the following C program:
#include <stdio.h>
typedef struct {
    char *a;
    char *b;
    } t;
void f1 (t s);
void f2 (t *p);
main()
{
    static t s = {"A", "B"};
    printf ("%s %s\n", s.a, s.b);
    f1(s);
    printf ("%s %s\n", s.a, s.b);
    f2(&s);
}
void f1 (t s)
{
    s.a = "U";
    s.b = "V";
    printf ("%s %s\n", s.a, s.b);
    return;
}
void f2(t *p)
{
    p -> a  = "V";
    p -> b = "W";
    printf("%s %s\n", p -> a, p -> b);
    return;
}
What is the output generated by the program ?

Q58GATE 20041 markMCQ−0.33 if wrong
Choose the correct option to fill the ?1 and ?2 so that the program prints an input string in reverse order. Assume that the input string is terminated by a new line character.
#include <stdio.h>
void wrt_it (void);
int main (void)
{
    printf("Enter Text"); 
    printf ("\n");
    wrt_it();
    printf ("\n");
    return 0;
}
void wrt_it (void)
{
    int c;
    if (?1)
        wrt_it();
    ?2
} 

Q59GATE 20041 markMCQ−0.33 if wrong
What is the output of the following program?
#include <stdio.h>
int funcf (int x);
int funcg (int y);
main ()
{
    int x = 5, y = 10, count;
    for (count = 1; count <= 2; ++count) {
        y += funcf(x) + funcg(x);
        printf ("%d", y);
    }
}
funcf (int x) {
    int y;
    y = funcg(x);
    return (y);
}
funcg (int x) {
    static int y = 10;
    y += 1;
    return (y + x);
}
 

Q60GATE 20041 markMCQ−0.33 if wrong
Consider the following C function:
 int f(int n)
{
   static int i = 1;
   if (n >= 5)
      return n;
   n = n+i;
   i++;
   return f(n);
}
The value returned by f(1) is

Keep practising

Topics in Programming in C

All CS topics ›