C ANSI - Sample Interview Question (Junior Level)

Considering the code below, which of the following printResult  implementations will output 13

#include <stdio.h>
#include <string.h>

int addNumbers(int a, int b) {
    return a+b;
}


int main()
{
    
    int (*foo)(int,int);
    foo = &addNumbers;
    printResult(foo,6,7);
    return 0;
}

  1. void printResult(int (&someFunc)(int, int),int a,int b) {
    int sum = (someFunc)(a, b);
    printf("%d",sum);
    }
  2. void printResult(int (*someFunc)(int, int),int a,int b) {
    int sum = (*someFunc)(a, b);
    printf("%d",sum);
    }
  3. void printResult(int (someFunc)(int, int,int a,int b) {
    int sum = someFunc(a, b);
    printf("%d",sum);
    }
  4. None of the above
Tests in C ANSI for Juniors

Test Name Difficulty Time (minutes) No. of Questions
C ANSI Online Test for Juniors C ANSI Junior 60 30

More Specific Tests in C ANSI for Juniors

Test Name Difficulty Time (Minutes) No. of Questions
C-Data-Types,-structs-and-unions Online Test for Juniors C - Data Types, structs and unions Junior 20 10
C-Pointers,-Arrays-and-Strings Online Test for Juniors C - Pointers, Arrays and Strings Junior 20 10
C-Standard-Library Online Test for Juniors C - Standard Library Junior 20 10