Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to demonstrate the use of a struct for managing book data.

Medium

Problem Statement

Write a program to demonstrate the use of a struct for managing book data.

Sample Input

Define a struct Book with title, author, and price.

Sample Output

Title: 1984
Author: George Orwell
Price: $15.99

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #include <string> struct Book { std::string title; std::string author; float price; }; int main() { Book book1; // Logic to manage book data return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
Define a struct Book with title, author, and price.
Expected Output
Title: 1984
Author: George Orwell
Price: $15.99