typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); } ,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
typedef struct error{int warning, error, exception;}error;
main()
    {
        error g1;
        g1.error =1;
        printf("%d",g1.error);
     }

1

The three usages of name errors can be distinguishable by the compiler at any instance, so valid (they are in different namespaces).
Typedef struct error{int warning, error, exception;}error;

This error can be used only by preceding the error by struct kayword as in:

struct error someError;

typedef struct error{int warning, error, exception;}error;

This can be used only after . (dot) or -> (arrow) operator preceded by the variable name as in :
g1.error =1;
            printf("%d",g1.error);
            typedef struct error{int warning, error, exception;}error;
This can be used to define variables without using the preceding struct keyword as in:

error g1;

Since the compiler can perfectly distinguish between these three usages, it is perfectly legal and valid.

More interview questions and answers

# 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); }

What is operator overloading?what r the advantages of operator overloading?

main() { char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]) { a++; printf("%c",*a); a++; printf("%c",*a); }

func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }

void main() { static int i=5; if(--i) { main(); printf("%d ",i); } }

What is the compilation difference at the compiler level for C++, VC++ and C# ?

void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }

void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }

void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }

Why an empty Structure will occupy 2Bytes in C++

void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }

void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

What is structure padding.Describe briefly?

void main() { int i=i++,j=j++,k=k++; printf("%d%d%d",i,j,k); }

void main() { static int i=i++, j=j++, k=k++; printf("i = %d j = %d k = %d", i, j, k); }

Why the size of empty Class is one byte?

void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }

#include main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }

main() { int a[10]; printf("%d",*a+1-*a+3); }

#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }

main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }

main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(" %d",i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); }

void pascal f(int i,int j,int k) { printf("%d %d %d",i, j, k); } void cdecl f(int i,int j,int k) { printf("%d %d %d",i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

What are anonymous structure, unions and what are their uses?

main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

What is the difference between char str, char *str and char* str ?Explain the meaning of char* or int* ?

Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

void main() { if(~0 == (unsigned int)-1) printf("You can answer this if you know how values are represented in memory"); }

int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

main() { char *p = "ayqm"; printf("%c",++*(p++)); }

main() { int i=5; printf("%d",++i++); }

main() { char *p = "ayqm"; char c; c = ++*p++; printf("%c",c); }

While copying the objects if we say X a=b, X a(b) What will it call, assignment operator or copy constructor? Justify

int aaa() {printf("Hi");} int bbb(){printf("hello");} iny ccc(){printf("bye");} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }

main() { int i=5; printf("%d",i=++i ==6); }

What are the disadvantages of C++?

main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

void ( * abc( int, void ( *def) () ) ) ();

Explain why encapsulation is required?

main() { while (strcmp("some","some\0")) printf("Strings are not equal\n"); }

main() { char str1[] = {"s","o","m","e"}; char str2[] = {"s","o","m","e","\0"}; while (strcmp(str1,str2)) printf("Strings are not equal\n"); }

What are Polymorphic Classes?

main() { int i = 3; for (;i++=0;) printf("%d",i); }

What is public, protected, private?

void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf("%d",*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf("%d",*cptr); }

void main() { static int i; while(i<=10) (i>2)?i++:i--; printf("%d", i); }

main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }

What is virtual class and friend class?

1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

What do you mean by pure virtual functions?

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

main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }

main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

What is the diffrence between static_cast and dynamic_cast in RTTI

main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }

What is a fake pointer?

What is importance of const. pointer in copy constructor?

What is the difference between a pointer and a reference?

What is Smart Pointer?

How to Configure SMTP in asp .NET?

Print Hello World message using SharePoint in Asp.Net 2.0?

How to create a SharePoint web part using File upload control.give example?

What is BulletedList Control in Share Point. Give an example?

DescribeWizard server control with example in Share Point?

Define Life Cycle of Page in ASP.NET?

Write a program in ASP.NET to Show Data With Access?

Write a program to show connection with Oracle in ASP.NET?

Write a program to show connection to Excel in ASP.NET?

How to add Record in ASP.NET?

Write a program to Delete Record in ASP.NET ?

Write a program to show data in Gridview in ASP.NET?

Write a Program to Connect with dropdownlist in ASP.NET

How Repeater is used in ASP.NET?

R4R provides free online tutolrails ,examples for Freshers and experts .We cover core java, tutorials, spring, Hibernate, python, struts, struts 2,c language, spring boot,PHP,MYSQL,C#,ASP.NET,WPF,WCF,Photoshop , JSP, programming, example, Interview questions and answer