"For every success of a man there will be a countless pain in his heart and that pain makes him a successful person in life"

When You are at the Peak of Concentration, You don't feel whether u r programming in C/C#/JAVA or any other, You just type the keys on keyboard and your sub-conscious mind does the rest...!

Myspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace Glitters




 
   

C Tricky Snippets

   
 


 

 

Home

Guestbook

GALLERY

MySQL

C/C++ Interview Questions

C/C++ Test Paper 1

C/C++ Test Paper 2

C Tricky Snippets

C - Pointers

C - Functions

C - Iterations, Operators

Java Interview Questions

Java Fundamentals

Java FAQs

J2EE - FAQs

Java - Best Collection Ever

Java/J2EE Test 1

Java Test 2

Java Servlets - FAQs

SCJP 5.0 Syllabus

SCJP Exam 1

SCJP Exam 2

SCJP Exam 3

SCJP Exam 4

SCJP Exam 5

Relational Database Management Systems(RDBMS) Imp. Concepts

SQL Server - Interview Questions

SQL Server 2

Data Structures

OOPS - FAQs

Object Oriented Programming (OOP) Concepts

Operating Systems - FAQs

Operating System Concepts

Networking Concepts

UML - Quick Reference

VB - FAQs

Secrets About Windows Operating Systems

 


     
 

 

main()
{
int i;
clrscr();
printf("%d", &i)+1;
scanf("%d", i)-1;
}
 
 
 
 
             Runtime error. Access violation
 
             Compile error. Illegal syntax
 
             None of the above
 
             Runtime error
 
c
 
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
 
 
 
             Gets into Infinite loop
 
             Compile error. Illegal syntax
 
             None of the above
 
             Runtime error.
 
b
 
main()
{
int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("n %d", i);
}
 
 
 
             Some Integer not 100
 
             100
 
             Runtime error.
 
             None of the above
 
D
 
main()
{
int i = 0xff ;
printf("n%d", i<<2);
}
 
 
 
             1020
 
             512
 
             4
 
             1024
 
A
 
#define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
 
 
 
             15
 
             225
 
             1
 
             none of the above
 
 
B
union u
{
  struct st
 {
       int i : 4;
       int j : 4;
       int k : 4;
       int l;
 }st;
 int i;
}u;
main()
{
    u.i = 100;
    printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
 
 
 
             40, 4, 0
 
             100, 4, 0
 
             0, 0, 0
 
             4, 4, 0
 
B
 
union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("n%d", sizeof(u));
printf(" %d", sizeof(u.a));
// printf("%d", sizeof(u.a[4].i));
}
 
 
 
             None of the Above
 
             1, 100, 1
 
             40, 4, 4
 
             4, 4, 4
 
 
A
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; // Address of i is assigned to pointer p
printf("%f", i/(*p) ); // i is divided by pointer p
}
 
 
 
             Compile error
 
             1.00000
 
             Runtime error.
 
             0.00000
 
A
 
main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
 
 
 
             Compile error
 
             0, 0
 
             Runtime error.
 
             the first two values entered by the user
 
D
 
main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
 
 
 
             Compile error
 
             “Hello world”
 
             Runtime error.
 
             “hello world”
 
B
 
 
 
 
 
main()
{
char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);
}
 
 
 
             Compile error
 
             I am OK
 
             Runtime error.
 
             I am O
 
A
 
How will you print % character?
 
 
 
             printf(“%%”)
 
             printf(“\%”)
 
             printf(“%”)
 
             printf(“%%”)
 
A
 
const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf("%d",perplexed);
}
 
 
 
             none of the above
 
             4
 
             2
 
             0
 
B
 
 
 
 
 
 
 
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
 
 
 
             Name
 
             compile error
 
             Your Name
 
             Runtime error
 
C
 
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
 
 
 
             Your Name Your Name
 
             Your Address, Your Address
 
             Your Name, Your Address
 
             None of the above
 
D
 
main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));
}
 
 
 
             HelloWorld
 
             Hello World
 
             Hello
 
             None of the above
 
B
 
main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcpy(a,b));
}
 
 
 
             None of the above
 
             “HelloWorld”
 
             “Hello World”
 
             “Hello”
 
A
 
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}

main()
{
int a[10][10];
func1(a);
func2(a);
}
 
 
 
             Ok it worksWill this work?
 
             Will this work?
 
             Ok it works
 
             None of the above
 
A
 
 
main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
 
 
 
             4, 100
 
             2, 100
 
             2, 2
 
             4, 4
 
 
 
C
 
main()
{
int i = 100;
clrscr();
printf("%d", sizeof(sizeof(i)));
}
 
 
 
             none of the above
 
             4
 
             100
 
             2
 
D
 
main()
{
int c = 5;
printf("%d", main||c);
}
 
 
 
             none of the above
 
             0
 
             5
 
             1
 
 
 
D
 
main()
{
char c;
int i = 456;
clrscr();
c = i;
printf("%d", c);
}
 
 
 
             none of the above
 
             random number
 
             -456
 
             456
 
A
 
void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
 
 
 
             none of the above
 
             10, 11
 
             10, 9
 
             10, 10
 
A
 
main()
{
int i =10, j = 20;
clrscr();
printf("%d, %d, ", j-- , --i);
printf("%d, %d ", j++ , ++i);
}
 
 
 
             20, 9, 19, 10
 
             20, 9, 20, 10
 
             20, 10, 20, 10
 
             19, 9, 20, 10
 
A
 
main()
{
int x=5;
clrscr();
for(;x==0;x--) {
printf("x=%dn”", x--);
}
}
 
 
 
             none of the above
 
             0, 1, 2, 3, 4
 
             1, 2, 3, 4, 5
 
             4, 3, 2, 1, 0
 
A
 
main()
{
int x=5;
for(;x!=0;x--) {
printf("x=%dn", x--);
}
}
 
 
 
             5, 3, 1
 
             4, 3, 2, 1, 0
 
             5, 4, 3, 2,1
 
             none of the above
 
D
 
 
main()
{
int x=5;
clrscr();
for(;x<= 0;x--)
{
printf("x=%d ", x--);
}
}
 
 
 
             5, 3, 1, -1, 3
 
             5, 2, 1
 
             5, 3, 1
 
             None of the above
 
D
 
 
main()
{
{
unsigned int bit=256;
printf("%d", bit);
}
{
unsigned int bit=512;
printf("%d", bit);
}
}
 
 
 
             256, 512
 
             512, 512
 
             256, 256
 
             Compile error
 
A
 
 
main()
{
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("%dn", 1L << i);
}
}
 
 
 
             1, 2, 4, 8, 16
 
             0, 1, 2, 4, 8
 
             0, 1, 2, 3, 4
 
             5, 4, 3, 2, 1
 
A
 
 
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%dn", bit = (bit >> (i - (i -1))));
}
}
 
 
 
             128, 64, 32, 16, 8
 
             256, 128, 64, 32, 16
 
             512, 256, 128, 64, 32
 
             64, 32, 16, 8, 4
 
B
 
main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%dn", bit >> (i - (i -1)));
}
}
 
 
 
             512, 512, 512, 512, 512
 
             256, 256, 0, 0, 0
 
             512, 256, 0, 0, 0
 
             256, 256, 256, 256, 256
 
 
D
 
 
main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}
 
 
 
             none of the above
 
             compile error
 
             OK I am gone
 
             OK I am done
 
D
 
 
main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}
 
 
 
             none of the above
 
             compile error
 
             OK I am gone
 
             OK I am done
 
D
 
 
main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
 
 
 
             0, -513
 
             512, 0
 
             0, 513
 
             0, 0
 
A
 
What would be the output of the following program?
main()
{
     int i=4; 
     switch(i) 
     { 
          default: 
          printf("n A mouse is an elephant built by the Japanese"); 
          case 1: 
               printf(" Breeding rabbits is a hair raising experience"); 
               break; 
          case 2: 
               printf("n Friction is a drag"); 
               break; 
          case 3: 
               printf("n If practice make perfect, then nobody's perfect"); 
     }
}
 
 
 
             

 

a) A mouse is an elephant built by the Japanese
 
 
             

 

b) Breeding rabbits is a hare raising experience
 
 
             c) A mouse is an elephant built by the Japanese Breeding rabbits is a hare raising experience
 
             d) None of the above
 
A
 
What is the output of the following program?
#define SQR(x) (x*x)
main()
{
     int a,b=3;
     a= SQR(b+2);
     printf("%d",a);
}
 
 
 
             25
 
             11
 
             Error
 
             Garbage Value
 
B
 
 
In which line of the following, an error would be reported?
1. #define CIRCUM(R) (3.14*R*R);
2. main()
3. {
4. float r=1.0,c;
5. c= CIRCUM(r);
6. printf("n%f",c);
7. if(CIRCUM(r))==6.28)
8. printf("nGobbledygook");
9. }
 
 
 
             

 

Line 1
 
 
             

 

Line 5
 
 
             

 

Line 6
 
 
             

 

Line 7
 
D
 
 
We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind()
 
 
 
             True
 
             False
 
A
 
If the program (myprog) is run from the command line as myprog 1 2 3 , What would be the output?
main(int argc, char *argv[])
{
   int i;
   for(i=0;i<argc;i++)
   printf("%s",argv[i]);
}
 
 
 
             1 2 3
 
             C:MYPROG.EXE123
 
             MYP
 
             None of the above
 
B
 
If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output?
main(int argc, char *argv[])
{
   int i,j=0; 
   for(i=0;i<argc;i++) 
   j=j+ atoi(argv[i]); 
   printf("%d",j);
}
 
 
 
             1 2 3
 
             6
 
             error
 
             "123"
 
B
 
 
If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday
What would be the output?
main(int argc, char *argv[])
{
while(--argc >0)
printf("%s",*++argv);
}
 
 
 
             myprog monday tuesday wednesday thursday
 
             monday tuesday wednesday thursday
 
             mondaytuesdaywednesdaythursday
 
             myprog tuesday thursday
 
C
 
 
What would be the output of the following program?
main()
{
int y=128;
const int x=y;
printf("%d",x);
}
 
 
 
             128
 
             Garbage value
 
             Error
 
             0
 
A
 
 
Following declarations are same
const char *s;
char const *s;
 
 
 
             True
 
             False
 
A
 
 
What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
 
 
 
             1 1 1
 
             1 2 4
 
             2 4 4
 
             4 4 4
 
 
C
 
 
Following declarations are different from one another
const char *const s;
char const *const s;
 
 
 
             True
 
             False
 
 
A
 
 
If the following program (myprog) is run from the command line as myprog friday tuesday sunday,  What would be the output?
main(int argc, char*argv[])
{
printf("%c",**++argv);
}
 
 
 
            m

 

 
             f
 
             myprog
 
             friday
 
B
 
 
 
If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char *argv[])
{
printf("%c",*++argv[1]);
}
 
 
 
             r
 
             f
 
             m
 
             y
 
A
 
 
Would the following program compile?
main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf("n%u%u",j,k);
}
 
 
 
             Yes
 
            No

 

 
A
 
 
According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
 
 
 
             

 

main(int argc, char *argv[])
 
 
             main(argc,argv) int argc; char *argv[];
 
             main() {int argc; char *argv[]; }
 
             None of the above
 
 
A
 
 
 
What would be the output of the following program?
main()
{
const int x=5;
int *ptrx;
ptrx=&x;
*ptrx=10;
printf("%d",x);
}
 
 
 
             5
 
             10
 
             Error
 
             Garbage Value
 
B
 

 
 

 

 

Thank You.. Visit Again

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free