logo

Crowdly

Browser

Add to Chrome

Course 31709

Looking for Course 31709 test answers and solutions? Browse our comprehensive collection of verified answers for Course 31709 at lms.aub.edu.lb.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

What happens if you forget to free memory allocated with malloc()?

View this question

Employee Management System 

Write a C program that: 

  • Defines a struct Employee with the following fields: 
    • char name[50] 
    • int id 
    • float salary 
  • Dynamically allocates an array of n employees in the heap (where n is entered by the user). 
  • Reads employee data (name, ID, and salary) from the user and stores it in the allocated memory. 
  • Implements a function printEmployees to display all employee records. 
  • Implements a function findTopEmployee that returns the employee with the highest salary. 
  • Frees allocated memory before exiting. 

Example Output: 

Enter the number of employees: 3 

Enter employee 1 name: Alice 

Enter employee 1 ID: 101 

Enter employee 1 SALARY: 3800 

Enter employee 2 name: Bob 

Enter employee 2 ID: 102 

Enter employee 2 SALARY: 3500 

Enter employee 3 name: Charlie 

Enter employee 3 ID: 103 

Enter employee 3 SALARY: 3900 

Employee Records: 

Alice (ID: 101, SALARY: 3800) 

Bob (ID: 102, SALARY: 3500) 

Charlie (ID: 103, SALARY: 3900) 

Top Employee: Charlie (ID: 103, SALARY: 3900)

View this question

#include "stdio.h"

int main()

{

struct {int a[2];} arr[] = {{1},{2}};

printf("%d %d %d %d",arr[0].a[0],arr[0].a[1],arr[1].a[0],arr[1].a[1]);

return 0;

}

Pick the best statement for the program above:

View this question

What header file is needed to use malloc() and free()?

View this question

We use malloc and calloc for

View this question

Which of the following operators can be applied on structure variables?

View this question

What is the return type of malloc() or calloc()

View this question

Want instant access to all verified answers on lms.aub.edu.lb?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome