Question

In: Computer Science

Create a nested structure in C (one structure that contains another) and print out all the...

Create a nested structure in C (one structure that contains another) and print out all the fields in both structures. The main structure should have fields for: movie name and the year it was released. The extended structure should include the original structure as well as fields for: Lead actor, genre and runtime.

Solutions

Expert Solution

Programming Language C program which has a nested structure and displays all the field of both the structure.

#include <stdio.h>
#include <string.h>

//structure Movie
struct Movie
{
//variable declaration
char movieName[50];
int movieYear;
};
//structure MovieExt
struct MovieExt
{
//variable declaration
char leadActor[50];
char genre[50];
int runtime;
//struct Movie variable declaration
struct Movie m;
};

int main()
{
struct MovieExt mov = {"ABC", "DEF", 10, "PQR", 2009};
//display actor, genre, runtime, name, and year
printf("Lead Actor: %s \n", mov.leadActor);
printf("Genre: %s \n", mov.genre);
printf("Runtime: %d \n\n", mov.runtime);
printf("Name: %s \n", mov.m.movieName);
printf("Year: %d \n", mov.m.movieYear);
return 0;
}

OUTPUT:

Lead Actor: ABC                                                                                                                 

Genre: DEF                                                                                                                      

Runtime: 10                                                                                                                     

                                                                                                                                

Name: PQR                                                                                                                       

Year: 2009


Related Solutions

3) Create a nested structure (one structure that contains another) and print out all the fields...
3) Create a nested structure (one structure that contains another) and print out all the fields in both structures. The main structure should have fields for: movie name and the year it was released. The extended structure should include the original structure as well as fields for: Lead actor, genre and runtime. In C 4) Create a structure for an employee which contains a field for: first name, last name, id and salary. Then use printf and scanf to fill...
C++ In this lab you will be using nested for loops to print out stars in...
C++ In this lab you will be using nested for loops to print out stars in a Diamond pattern such as this: * *** ***** ******* ********* *********** ************* *************** ************* *********** ********* ******* ***** *** * For example , if number of rows=8 then the above pattern is derived. You are to take the input for the number of lines(rows) from a file named "input_diamond" and output the pattern into both the terminal and an output file named "output_diamond".
In C Create a multi-dimensional array and print it out forwards, backwards and then transpose.
In C Create a multi-dimensional array and print it out forwards, backwards and then transpose.
JAVA Write nested while loop that will print out this pattern, based upon a number entered...
JAVA Write nested while loop that will print out this pattern, based upon a number entered by the user. User enters 4: 1234 1234 1234 1234 User enters 2: 12 12
Write a C program that contains a structure that uses predefined types and union. • Create...
Write a C program that contains a structure that uses predefined types and union. • Create a struct with name, age, kind (Either child, college student, or adult), and kindOfPerson (Either kid, student, or adult) • kids have a school field. Students have college and gpa. Adults have company and salary. • Create one non-dynamic struct with the content for a college student: "Bob", 20, K-State, 3.5 • Create one struct dynamically for a kid with: "Alison", 10, "Amanda Arnold...
Write a C++ function to print out all unique letters of a given string. You are...
Write a C++ function to print out all unique letters of a given string. You are free to use any C++ standard library functions and STL data structures and algorithms and your math knowledge here. Extend your function to check whether a given word is an English pangram (Links to an external site.). You may consider your test cases only consist with English alphabetical characters and the character.
C++: Write correct C++ code for a nested if-else if-else structure that will output a message...
C++: Write correct C++ code for a nested if-else if-else structure that will output a message based on the logic below. A buyer can pay immediately or be billed. If paid immediately, then display "a 5% discount is applied." If billed, then display "a 2% discount is applied" if it is paid in 30 days. If between 30 and 60 days, display "there is no discount." If over 60 days, then display "a 3% surcharge is added to the bill."...
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print...
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print out "n" lines as follows: 0 0 1 0 1 2 0 1 2 3 … 0 1 2 3 … n-1
1.If one statement is nested within another statement, as in a loop or recursive call, what...
1.If one statement is nested within another statement, as in a loop or recursive call, what is the running time of the two statements when considered as a block? the running time for the inner statement added to the running time for the outer statement the running time for the inner statement multiplied by the running time for the outer statement the running time for the inner statement divided by the running time for the outer statement the running time...
In C 1- Use nested for loops to create an addition lookup table. Fill in an...
In C 1- Use nested for loops to create an addition lookup table. Fill in an array and print out the following table showing the sum of the row and column numbers 0-9. 0 1 2 3 4.. <- column numbers 1 2 3 4 5.. 2 3 4 5 6.. <- These nos. = Row + Column 3 4 5 6 7.. <- for example 7 = 3 + 4 4 5 6 7 8.. ... ^Row numbers 2-...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT