[Solved] Enrolling the Events with C++

Enrolling the Events: Be it a concert, conference, corporate event or weddings, people have started to take interest in all kinds of events equally and actively. Silver Bells is an organization with creative and innovative ideas working towards making every Event, an unforgettable experience. Agnes, the founder of the Company wanted to develop an Event Management System that would let its Clients plan and host events seamlessly.

The primary requirement of the Event management System would be to enroll the details of any Event as given by the Clients. Agnes has assigned you the responsibility to write a program that will create a structure named Event with four members i.e, name(String), type(String), duration(int in days) and expenses (in lakhs, float). Below is the Event structure:

struct Event
{
char name[50];
char type[50];
int duration;
float expenses;
};

Your program should get the details of an Event and display the same in the main method. Can you accomplish the responsibility by following the requirements given?

Input Format:
First input should contain a string that gives the name of the Event.
Second input should contain a string that gives the type of the Event.
Third input should contain an integer that gives the duration of the Event.
Fourth input should contain a float value that gives the projected expenses of the Event.

Output Format:
Output should display the Event name, Type, Duration and the projected expense in separate lines.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output.]

Sample Input and Output:
Enter the name of the event
Food Fest 2017
Enter the type of the event
Public
Enter the duration (in days) of this event
3
Enter the projected expenses (in lakhs) for the event
5.7
Event Name : Food Fest 2017
Event Type : Public
Event Duration : 3 days
Projected Expense : 5.7L

Solution

#include <iostream>
#include <string.h>
using namespace std;

struct Event
{
    char name[50];
    char type[50];
    int duration;
    float expenses;
};

int main()
{
    char e[100];
    // sauravhathi
    char n[500];
    char t[500];
    int p;
    float ex;
    printf("Enter the name of the event\n");
    fgets(e, sizeof(e), stdin);
    printf("Enter the type of the event\n");
    fgets(n, sizeof(n), stdin);
    printf("Enter the duration (in days) of this event\n");
    scanf("%d", &p);
    printf("Enter the projected expenses (in lakhs) for the event\n");
    scanf("%f", &ex);
    Event event;
    strcpy(event.name, e);
    strcpy(event.type, n);
    event.duration = p;
    event.expenses = ex;
    printf("Event Name : %s", event.name);
    printf("Event Type : %s", event.type);
    printf("Event Duration : %d\n", event.duration);
    printf("Projected Expense : %.1fL", event.expenses);
    return 0;
}

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *