Are you a candidate looking to sharpen your skills? Try our practice tests or view sample interview questions & Get hired by the best. Click Here×

Online C Programming Quiz Test

Topics Covered

  • Memory Management
  • Pointers
  • Function prototype
  • Decision making - branching & looping
  • Debugging C Programs
  • File handling
  • Advance C ( Used for System Programming such as OS
  • Compilers
  • Kernels etc)

Useful for hiring

  • C Programmers
  • Software Developer (0-2 yrs experience)
  • Senior Software Engineer

Start hiring job-fit candidates using this assessment

GET A DEMO

"The best part of Interview Mocha is they have topic wise questions available. The skill wise extensive reports and advanced analytics lets us measure & benchmark the proficiency level of employees in that particular skill."

Cheryl Tolkinen, Securian, USA,
Learning & Development Manager
Question

Consider the following code snippet, first printf statement prints a value 3, what value will be printed by the second printf statement?
(Note: No other new file descriptors are opened while executing this program) 

int main()
{
     int df1= dup(STDOUT_FILENO);
     int df2= dup(STDOUT_FILENO);
     printf("%d", df1);
     printf("%d", df2);
     return 0;
 }

Answer
    • Any positive value

    • Error: Reduntant command

    • 1

    • 4

    • 0

Question

Given the code snippet:
int main() {
    int p1 = fork();
    int p2 = fork();
    if(p1 == 0 || p2 == 0) {
     printf("Hello\n");
    }
  return 0;
}

How many times will Hello be printed?

Answer
    • 1

    • 2

    • 3

    • 4

Question

Predict the output of the given program.

int main()
{
        int c = 0;
        c++;
        int p1 = fork();
        c++;
        int p2 = fork();
        c++;
        if(p2 == 0)
        {
                printf("%d\n", c);
        }
        return 0;
}

Answer
    • 1
      2
      3

    • 2
      3

    • 3
      3

    • 1
      1
      1

Good News! You can customize this test as per your requirement

  • Choose and add questions from Interview Mocha question libraries

  • Add your own set of questions

  • Customize test settings like duration, number of questions, passing score, web proctoring and much more

  • Mail us at support@interviewmocha.com to create a custom test

Looking for a tailor-made test, to suit your assessment needs?

Get in touch

Global companies using Mocha assessments

  • altran
  • credit suisse
  • sephora
  • nielsen
  • capgemini
  • akamai

How Mocha assessments are brewed

Speed up your IT recruitment with Interview Mocha

  • 500+ IT skill tests
  • 20+ coding languages
  • 50+ domain knowledge tests
  • 100+ digital 2.0 skill tests
  • Customer focus aptitude tests
  • Enterprise ready features & more...
GET A DEMO

Why hiring managers and recruiters across the globe love Interview Mocha

Take your first step to hire job fit candidates

GET A DEMO