PuzzlersWorld.com

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

Objective Questions set C/C++ – Part 1

(4 votes, average: 2.75 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) What will be the output of the program below

#include
main(){
    int num[] = {1,4,8,12,16};
    int *p,*q;
    int i;
    p =  num;
    q = num+2;
    i = *p++;
    printf("%d, %d, %d\n",i, *p, *q);
}

Options a) 4, 4, 8 b) 1, 4, 8 c) 2, 1, 8 d) 2, 4, 8

Tried enough already?
Q2) What will be the output of the program below

#include

main(){
char *a[4]={"jaya","mahesh","chandra","swapant"};
int i = sizeof(a)/sizeof(char *);
printf("i = %d\n", i);
}

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

Tried enough already?

Q3) What will be the output of the program below

#include
void fun(int *a, int *b)
{
    int *t;
    t=a;
    a=b;
    b=t;
}
main()
{
     int a=2;
     int b=3;
     fun(&a,&b);
     printf(%d, %d",a, b);
}

options: a) 3, 2 b) compilation error c) error at run time d) 2, 3 e) None of the above

Tried enough already?

Q4)

#include
#define scanf "%s is a string"
main()
{
 printf(scanf,scanf);
}

Options: a) compilation error b) runtime error c) %s is a string %s is a string d) %s is a string is a string e) None of the above

Tried enough already?

Q5)

 
#includemain(){
int i =(2+3, 4

Options: a) 4 b) 1 c) 0 d) 5 e) Compilation error

Tried enough already?
Q6)

#include
main(){
    int i =0;
    i = 2+3, 4>3, 3;
    printf("%d", i);
}

Options: a) 0 b) 3 c) 5 d) 4 e) Compilation error

Tried enough already?

Q7)

#include
int main(){
   char *p="abc";
   char *q="abc123";
   while(*p==*q)
   {
       printf("%c %c\n",*p,*q);
   }
}

Options: a) aabbcc b) aabbcc112233 c) aabbcc123 d) Infinite Loop e) Segmentation fault

Tried enough already?

Q8)

 
#include
int main(){
   char *p="abc";
   char *q="abc123";
   while(*p=*q)
   {
       printf("%c %c\n",*p,*q);
   }
}

Options: a) aabbcc b) aabbcc112233 c) aabbcc123 d) Infinite Loop e) Segmentation fault

Tried enough already?
Q9)

#include
main(){
    printf("%u", -1);
}

Options: a) -1 b) 1 c) 65535 d)Compilation Error e) None of the above

Tried enough already?
Q10)

#include
struct XX{
    float 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?
  • Share on Whatsapp
  • Share on Facebook
  • Share on Twitter
Facebook Comments
Next Puzzle
Objective Questions set C/C++ – Part 2

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

Leave a Comment Cancel reply

Submit your Puzzle

You may also like

  • implement isPalindrome(int n)
  • Fair and Square Solution: Google codejam 2013 Qual Round
  • Detect if there is a cycle in a linked list
  • Security problem solution: Facebook hacker cup 2013 Round 1
  • Consonants Solution: Google codejam 2013 Round 1C
  • Card Game solution: Facebook hacker cup 2013 Round1
  • Cookie Clicker Alpha Solution – Google Code Jam 2014
  • Beautiful Strings solution: Facebook hacker Cup 2013 Qual Round
  • Find middle element of linked list
  • Average speed of train

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