main( ) { char *q; int j; for (j=0; j<3; j++) scanf("%s" ,(q+j)); for (j=0; j<3; j++) printf("%c" ,*(q+j)); for (j=0; j<3; j++) printf("%s" ,(q+j)); } ,Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher
main( )
{
   char  *q;
   int  j;
   for (j=0; j<3; j++) 
   scanf("%s" ,(q+j));
   for (j=0; j<3; j++) 
   printf("%c" ,*(q+j));
   for (j=0; j<3; j++) 
   printf("%s" ,(q+j));
}

Here we have only one pointer to type char and since we take input in the same pointer thus we keep writing over in the same location, each time shifting the pointer value by 1. Suppose the inputs are MOUSE,  TRACK and VIRTUAL. Then for the first input suppose the pointer starts at location 100 then the input one is stored as

M     O     U     S     E     \0

When the second input is given the pointer is incremented as j value becomes 1, so the input is filled in memory starting from 101.

M     T     R     A     C     K     \0

The third input  starts filling from the location 102

M     T     V     I     R     T     U     A     L     \0

This is the final value stored .

The first printf prints the values at the position q, q+1 and q+2  = M T V

The second printf prints three strings starting from locations q, q+1, q+2

 i.e  MTVIRTUAL, TVIRTUAL and VIRTUAL.

More interview questions and answers
#include #define i 10 main() { #define i 50 printf("%d",i); }
#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }
main() { printf("%p",main); }
main() { clrscr(); } clrscr();
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
main() { int i=400,j=300; printf("%d..%d"); }
main() { char *p; p="java"; printf("%c\n",*&*p); }
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s
void main() { int a=5; printf("%d",a++ + ++a); }
void main() { int i=5; printf("%d",i+++++i); }
#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }
#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }
main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }
#include main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }
#include main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }
#include main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { extern int a; a=20; printf("%d",sizeof(a)); }
main() { printf("%d", out); } int out=100;
main() { printf("%d", out); } int out=100;
main() { extern out; printf("%d", out); } int out=100;
#include main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->na
#include main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }
#include main() { struct xx { int x; struct yy { char s; struct xx *p; }; stru
#include main() { struct xx { int x; struct yy { char s; struct xx *p; }; stru
main() { extern int i; i=20; printf("%d",sizeof(i)); }
main() { printf("%d", out); } int out=100;
main() { show(); } void show() { printf("I'm the greatest"); }
main( ) { int m[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf("%u %u %u %d \n",m,*m,**m,***m); printf("%u %u %u %d \n",m+1,*m+1,**m+1,***m+1); }
main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(�%d� ,*a); a++; } p = a; for(j=0; j<5; j++) {
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(�\n %d %d %d�, ptr-p, *ptr-a, **ptr); *ptr++; printf(
main( ){ static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(�\n %d %d %d�, ptr-p, *ptr-a, **ptr); *ptr++; printf(�\n %d %d %d�, ptr-p
Question : what is the difference between parameter and argument?
What is the difference between class and structure?
What is the difference between an object and a class?
Difference between realloc() and free()?
What is a template?
What is virtual constructors/destructors?
What is the difference between operator new and the new operator?
Difference between "C structure" and "C++ structure".
What is the difference between "overloading" and "overriding"?
Difference between a "assignment operator" and a "copy constructor"
What is the advantage of function overloading according to users point of view?
What is difference between visual c++ & ANSI c++ ?
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); *ptr++; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); *++ptr; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); ++*ptr; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); }
main( ) { char *q; int j; for (j=0; j<3; j++) scanf("%s" ,(q+j)); for (j=0; j<3; j++) printf("%c" ,*(q+j)); for (j=0; j<3; j++) printf("%s" ,(q+j)); }
main( ) { void *vp; char ch = "g", *cp = "goofy"; int j = 20; vp = &ch; printf("%c", *(char *)vp); vp = &j; printf("%d",*(int *)vp); vp = cp; printf("%s",(char *)vp + 3); }
main ( ) { static char *s[ ] = {"black", "white", "yellow", "violet"}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf("%s",*--*++p + 3); }
main() { int i, n; char *x = "girl"; n = strlen(x); *x = x[n]; for(i=0; i
int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }
What are the files which are automatically opened when a C file is executed?
what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF)
main() { main(); }
main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }
main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }
main() { char not; not=!2; printf("%d",not); }
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }
main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }
#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }
What is the difference between far pointer and near pointer?
What are virtual functions?
What is RTTI?
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
What happens to the member function in the class when copy constructor is invoked?
main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }
#include main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }
#include main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }
#include main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }
main() { int i=5,j=6,z; printf("%d",i+++j); }
struct aaa{ struct aaa *prev; int i; struct aaa *next; }; main() { struct aaa abc,def,ghi,jkl; int x=100; abc.i=0;abc.prev=&jkl; abc.next=&def; def.i=1;def.prev=&abc;def.next=&ghi; ghi.i=2;ghi.prev=&def; ghi.next=&jkl; jkl.i=3;jkl.prev=&ghi;jkl.next=&abc; x=abc.next->next->prev->next->i; printf("%d",x); }
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }
main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }
main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }
main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }
main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }
# include int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }
What is the difference between block structured language and highly block structured language
# include aaa() { printf("hi"); } bbb() { printf("hello"); } ccc() { printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); }
#include main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }
main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }
How will you detect if there is memory leak in your C++ program?
main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }
What was the most difficult debug you have ever done?
int i; main() { int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p
main() { int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }
What is the use of new operator?
main() { unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
What is a scope resolution operator?
In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main() { int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }
What is namespace?
What are the following notations of defining functions known as? int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }
Difference between a "assignment operator" and a "copy constructor"
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }