mardi 11 octobre 2016

categorize people by age in C

i have to make a program for school but i'm having trouble on the third option.

Prints on-screen menu with the following options:

1.Capture company data 2.Print company data 3.Capture ages of employees 4.Exit

For option 3 you must read the ages of the employees of the company, while the read age is nonzero calculate the following: how many employees are younger than 22 years old, mature between 22 and 50 years and those who are older with more than 50 years old. Show the result on the screen. In cases where a non-correct age (negative or outside the range of 18 to 65 years) an error message on the screen.

so far my code looks like this for the other 2 options

#include <stdio.h>
#include <stdlib.h>



struct company{

char nompany[10];
char nuser[10];
int age;
}company;

struct company;

main()
{
int opc, resp;
do{

printf("1.Capture company data\n 2.Print company data\n 3.Capture ages of employees\n 4.Exit\n" );
scanf("%d", &opc);

switch(opc){
case 1:
printf("*****Capture company data *****\n");
printf("Enter name of the company: \n");
scanf("%s", &company.ncompany);
printf("Enter Username: \n");
scanf("%s", &company.nusername);


break;

case 2:
printf("*****Print company data*****\n");
printf("Name of company: %s \n", company.ncompany);
printf("username: %s \n", company.nusername);


break;

case 3:
printf("*****Capture ages of employees*****\n")
printf("Enter age os employees:  \n");






return 0;


}

Aucun commentaire:

Enregistrer un commentaire