473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Create a enum to choose what operation need to be perfomed like (Display class inform

1
What is the mistake in this program and the question is Create a enum to choose what operation need to be perfomed like (Display class information, show result, Fail students list, Pass students list ).
Create seperate function for each operation listed in above point.
Ask user to provide input and on the basis of user input call required function using function pointer.


#include<stdio.h>
#include<stdlib.h>
void Display_Information(char name1[],int date,int number,int mks[]);
void Show_result(char name1[],int date,int number,int mks[]);
void Pass_list(char name1[],int date,int number,int mks[]);
void Fail_list(char name1[],int date,int number,int mks[]);
enum ope{Display_Information=1,Show_result,Pass_list,Fa il_list};
enum ope info;
int main()
{
int n,name[50],dob,mks[5],i;
double mobile;
printf("Enter n value to enter student details: \n");
scanf("%d",&n);
printf("Enter %d student details: ",n);
printf("Enter Student name: ");
scanf("%s",name);
printf("Enter student birth date: ");
scanf("%d",&dob);
printf("Enter mobile number: ");
scanf("%lf",&mobile);
printf("Enter marks for 5 subjects: \n");
for(i=0;i<5;i++)
{
scanf("%d",&mks[i]);
}

void (*ptr_arr[])(char,int,int,int)={Display_Information,Show_resu lt,Pass_list,Fail_list};
int info;
printf("Student Record\n");
printf("1. Display_information\n");
printf("2. Show_result\n");
printf("3. Pass_list\n");
printf("4. Fail_list\n");
printf("Enter choice: \n");
scanf("%d",&info);
if(info>4)
return 0;
else
(*ptr_arr[info])(name,dob,mobile,mks);
return 0;
}
void Display_Information(char name1,int date,int number,int mks[])
{
int i;
printf("Given Information is: \n");
printf("Name: %s",name1);
printf("Date of birth is: %d",date);
printf("Mobile number is: %lf",number);
printf("Marks are :\n");
for(i=0;i<5;i++)
{
printf("%d ",mks[i]);
}
}
void Show_result(char name1,int date,int number,int mks[])
{
printf("%s marks are: \n",name1);
for(int i=0;i<5;i++)
{
printf("%d",mks[i]);
}
}
void Pass_list(char name1,int date,int number,int mks[])
{
printf("Pass marks are: \n");
for(int i=0;i<5;i++)
{
if(mks[i]>25)
{
printf("%d",mks[i]);
}
}
}
void Fail_list(char name1,int date,int number,int mks[])
{
printf("Fail marks are: \n");
for(int i=0;i<5;i++)
{
if(mks[i]<25)
{
printf("%d",mks[i]);
}
}
}
Nov 29 '18 #1
1 1138
weaknessforcats
9,208 Expert Mod 8TB
The first thing I see is that your enum value names are the same as your function names. The compiler now doesn't know what to do, so you get an error.


There may be other errors but fix this one first. All names in the code must be unique.
Nov 29 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: e01osama | last post by:
I am new to java. I inatalled oracle. I need to display some of the data from table. that table is from oracle.I want to know how to get that data in to interface. pls help.
3
by: Meena | last post by:
Hi Every Body, I have created a crystal Report and linked to my vb.net forms and working fine, I added more drill drowns in groups everything fine, but What I need is I am not able to display...
0
by: laizdex | last post by:
Dear all I can create a project or class wizard, but how could I create a method wizard for a specified class? Does somebody could give me some hint? Thanks a lot Chris
9
by: S Wheeler | last post by:
Hi all - I am trying to create an instance of a vb .net class containing a form from unmanaged vc++. The vb.net is a dll. How to do this ? I am trying #import by can't seem to get it quite...
1
by: Joseph Turian | last post by:
I try to compile the following: === typedef enum { CREATED, ADDED_TO_AGENDA, POPPED_FROM_AGENDA, DUMMY_LAST_CAT } DStatCat; class DerivationStatistics { .... private: enum {MAX_LENGTH =...
9
by: Peri | last post by:
Dear All, I have written a common array class which has insert, search and other functions. For Example (Code in VB.NET): ' Client Class Public Class Client Public ClientCode As String ...
2
by: mirzaali | last post by:
Hi All, I neeed to dispaly the data in html table tag Query :-select comp,total,funds from table1, WHICH WIL RETURN 3-RECORDSETS rs_query(0) rs_query(1) rs_query(2)
1
by: c0l0nelFlagg | last post by:
I need to display a main form with 48 identical subforms. 6 columns with 8 rows. I set up a separate query for each subform, identical in structure and underlying data except the criteria in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.