Electric Power Supply Complaint Registration Menu Driven Program using C language

Electric Power Supply Complaint Registration Menu Driven Program using C language

Here, in this program, we are creating a menu-driven program with the help of C language for the complaint registration under the electric power supply office.

Filename:- powersupply.c

#include<stdio.h>
#include<string.h> //including string header file for string functions
#include<math.h>
int menu()
{
 int press; //variable to take user input
 puts("Press 1 for Report Supply Off"); //menu choices
 puts("Press 2 for Register a Complaint");
 puts("Press 3 for New Connection Installation");
 puts("Press 4 for Low Voltage Fluctuations");
 puts("Press 5 for Register Electricity Theft");
 puts("Press 6 for Book a Visit to the Supply Office");
 scanf("%d",&press); //receiving value from user
 return press; //returning the user inputted value to the main function
}
void supplyoff() //supplyoff function definition
{
    int offtime;
    char lightpost[30];
    puts("How much time the supply is off?\n");
    puts("Press 1 for less than 1 hour");
    puts("Press 2 for more than 1 hour");
    scanf("%d",&offtime);
    if(offtime==1)
        puts("Your complaint is registered, the supply will be restored soon.");
    else if(offtime==2)
    {
        puts("Enter your nearest lightpost number:");
        scanf("%s",lightpost); //receiving lightpost number
        printf("Our executive is on the way to your area %s for recovery.\n", lightpost);
    }
    else
        puts("Sorry, invalid input!");
}
void regcomp() //regcomp function definition
{
    int phone[10];
    puts("May I know your Mobile Number:\n");
    scanf("%d",phone); //taking user's phone number
    printf("Your complaint is registered. Our technician will call you recently.\n");
}
void newconn() //newconn function definition for new connection
{
    char addr[50];
    puts("May I know your address:\n");
    scanf("%s",addr); //taking the address from user
    printf("Our executive will visit your address soon for the new connection.\n");
}
void bookvisit()
{
    printf("Your booking number is %d\n",rand()); //printing a random number for the booking
    puts("Please visit next week after 11.30am\n");
}
void voltf()
{
    char lightpost[30];
    puts("Enter your nearest lightpost number:");
    scanf("%s",lightpost);
    printf("Your complaint number is %d\n",rand());
    puts("Our experts will visit your area soon.\n");
}
void etheft()
{
    char addr[50];
    puts("May I know your address:\n");
    scanf("%s",addr);
    printf("Your complaint number is %d\n",rand());
    puts("Our experts will visit your address soon.\n");
}
void main()
{
char name[40], custid[12]; //character arrays
int i,choice; 
puts("Hello, Welcome in the Electric Power Supply Office\n");
puts("May I know your 12 digit customer ID please:\n");
gets(custid); //function to receive customer ID
puts("May I know your name please:\n");
gets(name); //String function to receive name
printf("%s tell me what is your problem?\n", name);
choice=menu();
switch(choice)
{
    case 1:supplyoff();break; //calling the functions from main
    case 2:regcomp();break; //according to the switch value
    case 3:newconn();break;
    case 4:voltf();break;
    case 5:etheft();break;
    case 6:bookvisit();break;
    default:puts("Invalid input! Start again.");
}
}

Output:-

Output power cut C program menu driven

Output voltage drop C program menu driven