Find Error if any in below code, Justify ur answer:

struct xx
{
int a;
struct yy
{
char c;
struct xx* p;
}
struct yy* q;
}




Answers were Sorted based on User's Feedback



Answer / vignesh1988i

here the error is the variable declaration of struct xx is not permitted inside struct yy. since this is nested structures ,so according to the braces for each structures the variables for that particular structure should be assigned (OR)
if this is written as code given below this will be correct.
THIS IS THE CORRECT CODE WHICH WILL GIVE NO ERROR.
struct xx
{
int a;
}
struct yy
{
char c;
struct xx *p;
}
struct yy *q

THE SAME CODE GIVEN IN THE QUESTION CAN BE CORRECTED AS :

struct xx
{
int a;
struct yy
{
char c;
}*q // for struct yy
}*p // for struct xx


thank u

Is This Answer Correct ?    4 Yes 1 No

Answer / raj

struct xx
{
int a;
struct yy
{
char c;
struct xx* p;
};//Semicolon is missing
struct yy* q;
}

Is This Answer Correct ?    0 Yes 4 No

Answer / lucky

threr is no error in this prg

Is This Answer Correct ?    0 Yes 5 No



Post New Answer



More C Interview Questions

WHAT IS HIGH LEVEL LANGUAGE?

2 Answers  


Code for calculating square root without using library function, of math.h

4 Answers   IBM,


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

0 Answers   Convergys,


True or false: If you continuously increment a variable, it will become negative? 1) True 2) False 3) It depends on the variable type

7 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

2 Answers   IBM, HCL, Satyam, Vimal, Vimukti Technologies,






What is true about the following C Functions a.Need not return any value b.Should always return an integer c.Should always return a float d.Should always return more than one value.

11 Answers   TCS,


write a program to compare 2 numbers without using logical operators?

5 Answers   IBM,


Which is the best sort method for library management?

1 Answers   Microsoft,


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

0 Answers  


what is the use of using linked list and array?

10 Answers   TCS, Infosys,


Magic square

0 Answers  


logic for x=y^n

1 Answers   Delphi,






Categories