PuzzlersWorld.com

  • Hacker Puzzle
  • Interview Puzzles
  • Number Puzzles
  • Maths Puzzles

Objective Questions set C/C++ – Part 2

(1 votes, average: 1.00 out of 5)

October 28, 2012 by asinghal Leave a Comment

10 Objective type interview questions with answers on C/C++

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Try yourself before giving up 🙂

Q1)

#include
struct XX{
    int a:10;
    int b:6;
    char c;
} structure;
int main(){
    int i = sizeof(structure);
    printf("%d", i);
}

Options: a) 4 b) 8 c) 9 d) 3 e) Compilation error

Tried enough already?

Q2)

#include
#include
main()
{
    char *s;
    s="hot java";
    strcpy(s,"solaris java");
    printf("%s", s);
}

Options:a) hot java b) solaris java c) compilation error d) Segmentation fault

Tried enough already?

Q3) In below code snippet, How many time solaris will be printed?

#include
main()
{
     int ret;
     ret=fork();ret=fork();ret=fork();ret=fork();
     if(!ret)
         printf("sun");
     else
         printf("solaris");
}

Options: a) 16 b) 1 c) 8 d) 4

Tried enough already?
Q4)
A program MIN takes integers as inline arguments and gives the smallest integer as output. What will be the value of argc if the program is invoked as “MIN 12 51 17 15” ?

Options: a) 4 b) 5 c) 1 d) 0

Tried enough already?
Q5)

#include
int main(int argc, char ** argv)
{
int x;
scanf(“%d”,x);
printf(“%d”, x);
}

Options: a) print the integer value given as input b) Compilation error c) Run time error d) None of the above

Tried enough already?
Q6)

#include
int main(int argc, char ** argv)
{
    int x=7;
    printf("%d", x++*x++);
}

Options: a) 56 b) 49 c) 72 d) 64

Tried enough already?
Q7)

#include
#include
main(){
    char string[10] = "abc";
    strcat(string, 'd');
    printf("%s", string);
}

Options: a) abc b) abcd c) d d) Compilation Error

Tried enough already?
Q8)

include
int f(int *a)
{
    int b =5;
    a = &b;
}

main(){
    int i =10;
    printf("%d",i);
    f(&i);
    printf(",%d",i);
}

Options: a) 10,10 b) 10,5 c) Compilation error d) Runtime error

Tried enough already?
Q9)

#include
void f(int i)
{
    int j;
    for (j=0;j<16;j++) { if (i & (0x8000>>j))
            printf("1");
        else
            printf("0");
    }
}

What is the purpose of the function ?
Options: a)prints hex representation of i b) prints decimal representation of i c) prints binary representation of i d) None

Tried enough already?
Q10)

#include
#define f(a,b) a+b
#define g(a,b) a*b

main()
{
    int m;
    m=2*f(3,g(4,5));
    printf("\n m is %d",m);
}

Options: a) 46 b) 70 c) 26 d) None of the above

Tried enough already?
  • Share on Whatsapp
  • Share on Facebook
  • Share on Twitter
Facebook Comments
Next Puzzle
Objective Questions set C/C++ – Part 3

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Leave a Comment Cancel reply

Submit your Puzzle

You may also like

  • Average speed of train
  • implement isPalindrome(int n)
  • Dead Pixels solution: Facebook hacker cup 2013 Round 1
  • Output of the recursive program
  • Detect if there is a cycle in a linked list
  • Subjective Question set C/C++ – Part 1
  • Objective Questions set C/C++ – Part 3
  • Permutations solution: Facebook hacker cup 2013 Round 2
  • Charging Chaos Solution – Google CodeJam
  • Find all non duplicate pairs that sum to S

Categories

  • Aive hi Puzzles
  • Akbar and Birbal
  • Alphabetical Puzzles
  • Bollywood Puzzles
  • Google Code jam
  • Hindi Riddles
  • Interview Puzzles
  • Interview Questions
  • Logical Puzzles
  • Malayalam Puzzles
  • Maths Puzzles
  • Miscellaneous
  • Number Puzzles
  • Picture Puzzles
  • Riddles
  • Tamil Puzzles
  • Technical

Social

  • View puzzlersworld’s profile on Twitter
privacy policy

Copyright © 2025 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in

  • Hacker Puzzle
  • Logo Puzzles
  • Optical Illusions
  • WhatsApp Puzzles
  • Picture Puzzles
  • Riddles
    â–¼
    • Hindi Riddles
  • Bollywood Puzzles
  • Alphabetical Puzzles
  • Aive hi Puzzles
  • Interview Puzzles
  • Logical Puzzles
  • Interview Questions
    â–²
    • Data Structures
    • Binary Tree
    • Algorithms
    • Recursion Questions
    • Amazon Interview Questions
    • Snapdeal Interview Questions
    • Google Code jam
  • Technical
  • Akbar and Birbal
  • Number Puzzles
  • Maths Puzzles
  • Miscellaneous