Click here to Skip to main content
15,943,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
char menuoption;
double i[4];
double employeenumber=0, hoursworked=1, payrate=2, tax=3;


printf("Please choose an option from the following menu:\n");
printf("A or a to add employee info\n");
printf("D or d to display employee info\n");
printf("T or t to display total payroll\n");
printf("S or s to display the info of all employees\n");
printf("Z or z to exit program\n");

scanf(" %c", &menuoption);

switch (menuoption)
//add employee info
case 'a': case 'A':
for(i=0; i<=5; i++)
	printf("Please enter employee number: ");
	scanf("&lf", &employeenumber);
	scanf("&lf", &employeenumber);
	printf("\nPlease enter hours worked: ");
	scanf("%lf", &hoursworked);
	printf("\nPlease enter hours worked: ");
	scanf("%lf", &hoursworked);
	printf("\nPlease enter the employee tax deduction: ");
	scanf("%lf", &tax);

This is my first time ever programming, and I don't understand how to store this information into an array... Anything will help!
Updated 26-Feb-15 7:34am
CPallini 26-Feb-15 13:35pm    
What information do you want to store in the array?
Sergey Alexandrovich Kryukov 26-Feb-15 15:45pm    
Listen to a good friendly advice: re-read your C textbook once again. The issue might be way too simple to ask questions. Anyway, make yourself more prepared for answers. :-)
Maciej Los 26-Feb-15 16:00pm    
My virtual 5!
Sergey Alexandrovich Kryukov 26-Feb-15 16:04pm    
Thank you, Maciej.
nv3 26-Feb-15 17:08pm    
Or read it the first time ever. My 5 as well.

There is static arrays and dymanically allocated arrays.

static array
//define and initialise
#define N 5
char c[N] = {'a','b','c','d','e'};
//change a value, index starts at 0
//access value
char y=c[3];

dynamic array:[^]

#include <stdlib.h>
//use malloc or calloc
char c[] = (char*)calloc(5,sizeof(char));
//when finished
Share this answer
Well let me help you out with something. You can use the arrays as:
double employeeArray[5];

here you can assign the variables to the elements of the array like:
employeeArray[0] = employeeNumber;

But, their is far better way to do this. I understand that you have just started with programming so it will take time to reach to the constructs called 'structs', but if you have many employee and each of them is having some details or information associated with them then you might consider using the structs.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900