11 Mar 2015

Basic level c practice structure enum union set1


3.   ADOBE

 #include<stdio.h>

main()

{

  struct xx

   {

      int x=3;

      char name[]="hello";

   };

struct xx *s=malloc(sizeof(struct xx));

printf("%d",s->x);

printf("%s",s->name);

}

Answer:

Compiler Error

Explanation:

Initialization should not be done for structure members inside the structure declaration


4.    TCS

main()

{

struct student

{

char name[30];

struct date dob;

}stud;

struct date

        { 

         int day,month,year;

         };

     scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month,      &student.dob.year);

}

Answer:

Compiler Error: Undefined structure date

Explanation:

Inside the struct definition of ‘student’ the member of type struct date is given. The compiler doesn’t have the definition of date structure (forward  reference is not allowed in C in this case) so it issues an error.

4 comments:

  1. Enum union Set is the part of all Programming Languages like C++, C#, Php, Python etc. Now here you told about the practice of Php and Enum is the important topic of this programming language. On the other hand, I need uk essays and it's good idea of practice you have showed here.

    ReplyDelete

  2. Schaffhausen rolex replica has been a global partner for replica watches the Lawrence Sports Foundation since 2005. In 2007, the replica watches uk
    luxury watchmaker and Switzerland Mercedes-Benz co-founded the Swiss Lawrence Foundation (Laureus Foundation Switzerland). The 9th Laurence Charity Night

    ReplyDelete
  3. Amid this period you confront the obstacle of dealing with your costs till your next payday. You don't just need cash to meet your essential needs additionally require money to meet any unanticipated cost.

    ReplyDelete