In: Computer Science
Instructions: You are givne main.c and exam.h. Your task is to implement exam.c. write the code for these 20 functions on repl.it.
*/
#include 
#include "exam/exam.h"
int main(void) {
  return 0;
}
/*
/*
exam.h
*/
#ifndef _EXAM_H_
#define _EXAM_H_
// 1
// Display title of code and your name. ( koorsh maghsoodi my name)
// See exam.txt for sample output.
void exam_hello_world(void);
// 2
// Display argc and all argv[] values.
// See exam.txt for sample output.
// returns: number of arguments
int exam_cmd_line_args(int argc, char *argv[]);
// 3
// Display info about signed integer data types.
// See exam.txt for sample output.
// Return number of signeed integer data types
int exam_signed_integer_data_types(void);
// 4
// Display info about unsigned integer data types.
// See exam.txt for sample output.
// Return number of unsigned integer data types
int exam_unsigned_integer_data_types(void);
// 5
// Display info about these data types:
// int8_t, uint8_t
// int16_t, uint16_t
// int32_t, uint32_t
// See exam.txt for sample output.
// Return number of unsigned integer data types
int exam_stdint_integer_data_types(void);
// 6
// Display info about floating-point data types.
// See exam.txt for sample output.
int exam_floating_data_types(void);
// 7
// Return the sum of three integer numbers.
// See exam.txt for sample output
int exam_sum(int n1, int n2, int n3);
// 8
// Given two integer numbers, return:
// -1 if n1 is less than n2
// 0 if n1 is equal to n2
// 1 if n1 is greater than n2
// See exam.txt for sample output
int exam_compare(int n1, int n2);
// 9
// Given two integer numbers,
// return the sum of n1 to n2.
// For example, if n1=2 and n2=4,
// return sum of 2+3+4, i.e. 9
// Do this using a for loop.
int exam_for(int n1, int n2);
// 10
// Given two integer numbers,
// return the sum of n1 to n2.
// For example, if n1=2 and n2=4,
// return sum of 2+3+4, i.e. 9
// Do this using a while loop.
int exam_while(int n1, int n2);
// 11
// Given two integer numbers,
// return the sum of n1 to n2.
// For example, if n1=2 and n2=4,
// return sum of 2+3+4, i.e. 9
// Do this using a do_while loop.
int exam_do_while(int n1, int n2);
// 12
// Display info about enum data types.
// See exam.txt for sample output.
typedef enum {
  EXAM_ERROR_OK = 0,
  EXAM_ERROR_BAD_PARAM,
  EXAM_ERROR_OUT_OF_RANGE,
  EXAM_ERROR_IO
} exam_error_t;
exam_error_t exam_typedef_enum_data_types(void);
// 13
// Add a student.
// If the max students is reached return
// EXAM_ERROR_OUT_OF_RAMGE,
// else return EXAM_ERROR_OK
// See exam.txt for sample output
#define EXAM_MAX_STUDENTS 3
typedef struct {
  int id;
  float average;
  char *name;
} student_t;
exam_error_t exam_add_student(student_t *s);
// 14
// List all students
// See exam.txt for sample output
// Return the number of students listed
int exam_list_students(void);
// 15
// Remove a student by id 
// See exam.txt for sample output
// Return EXAM_ERROR_OK if studentt was
// removed. Else return EXAM_ERROR_BAD_PARAM
exam_error_t exam_remove_student_by_id(int id);
// 16
// Remove a student by name
// See exam.txt for sample output
// Return EXAM_ERROR_OK if studentt was
// removed. Else return EXAM_ERROR_BAD_PARAM
exam_error_t exam_remove_student_by_name(char *name);
//17
// Write the list of students to a file.
// Return EXAM_ERROR_OK on success or
// Return EXAM_ERROR_BAD_PARAM if filenmae is NULL.
// Return EXAM_ERROR_IO if file write error
exam_error_t exam_write_students_to_file(char *filename);
//18
// Read the list of students from a file.
// Return EXAM_ERROR_OK on success or
// Return EXAM_ERROR_BAD_PARAM if filenmae is NULL.
// Return EXAM_ERROR_IO if file write error
exam_error_t exam_read_students_from_file(char *filename);
//19
// Given an array of students (e.g. just read in from a file)
// display them to the console.
// Return the number of students displayed.
int exam_display_students_from_list(student_t s[], size_t size);
//20
// For each of the following files, read them in,
// and then display the following info:
// Filename, Number of Lines, Number of Characters
// main.c....
// exam/exam.h....
// exam/exam.c...
// Return the total number of LINES of all files,
// i.e. lines of main.c + exam.h + exam.c
int exam_return_total_lines(void);
#endif
YOUR SAMPLE OUTPUT SHOULD LOOK LIKE THIS:
1 - exam_hello_world
        CSCI 112 Final
        Code by Norman McEntire
2 - exam_cmd_line_args
        argc: 4
        argv[0]: main
        argv[1]: one
        argv[2]: two
        argv[3]: three
value returned: 4
3 - exam_signed_integer_data_types
        type    size
        ----    ----
        char    1
        short   2
        int     4
        long    8
value returned: 4
4 - exam_unsigned_integer_data_types
        type    size
        ----    ----
        unsigned char   1
        unsigned short  2
        unsigned int    4
        unsigned long   8
value returned: 2
5 - exam_stdint_integer_data_types
        type            size
        ----            ----
        uint8_t         1
        uint16_t        2
        uint32_t        4
value returned: 3
6 - exam_floating_data_types
        type    size
        ----    ----
        float   4
        double  8
value returned: 2
7 - exam_sum
        n1: 10, n2: 20, n3: 30
value returned: 60
8 - exam_compare
        n1: -10, n2: 20
value returned: -1
8 - exam_compare
        n1: 10, n2: 10
value returned: 0
8 - exam_compare
        n1: 20, n2: 10
value returned: 1
9 - exam_for
        n1: 10, n2: 20
value returned: 165
10 - exam_while
        n1: 10, n2: 20
value returned: 165
11 - exam_do_while
        n1: 10, n2: 20
value returned: 165
12 - exam_typedef_enum_data_types
        EXAM_ERROR_OK: 0
        EXAM_ERROR_BAD_PARAM: 1
        EXAM_ERROR_OUT_OF_RANGE: 2
        EXAM_ERROR_IO: 3
13 - exam_add_student
        id: 123, average: 94.50, name: John
        Currrent num_students: 0
        Student added. updated num_students: 1
value returned: 0
13 - exam_add_student
        id: 234, average: 95.60, name: Sally
        Currrent num_students: 1
        Student added. updated num_students: 2
value returned: 0
13 - exam_add_student
        id: 345, average: 96.70, name: Billy
        Currrent num_students: 2
        Student added. updated num_students: 3
value returned: 0
13 - exam_add_student
        id: 456, average: 97.80, name: Paul
        Currrent num_students: 3
        Max number of students reachd!
value returned: 2
14 - exam_list_students
        Total of 3 students:
        id: 123, average: 94.50, name: John
        id: 234, average: 95.60, name: Sally
        id: 345, average: 96.70, name: Billy
value returned: 3
15 - exam_remove_student_by_id
        id: 234
        FOUND! Student removed!
value returned: 0
14 - exam_list_students
        Total of 2 students:
        id: 123, average: 94.50, name: John
        id: 345, average: 96.70, name: Billy
value returned: 2
15 - exam_remove_student_by_id
        id: 999
        NO STUDENT FOUND!
value returned: 1
14 - exam_list_students
        Total of 2 students:
        id: 123, average: 94.50, name: John
        id: 345, average: 96.70, name: Billy
value returned: 2
16 - exam_remove_student_by_name
        name: Billy Bob
        NO STUDENT FOUND!
value returned: 1
14 - exam_list_students
        Total of 2 students:
        id: 123, average: 94.50, name: John
        id: 345, average: 96.70, name: Billy
value returned: 2
16 - exam_remove_student_by_name
        name: No One
        NO STUDENT FOUND!
value returned: 1
14 - exam_list_students
        Total of 2 students:
        id: 123, average: 94.50, name: John
        id: 345, average: 96.70, name: Billy
value returned: 2
13 - exam_add_student
        id: 234, average: 95.60, name: Sally
        Currrent num_students: 2
        Student added. updated num_students: 3
value returned: 0
13 - exam_add_student
        id: 456, average: 97.80, name: Paul
        Currrent num_students: 3
        Max number of students reachd!
value returned: 2
14 - exam_list_students
        Total of 3 students:
        id: 123, average: 94.50, name: John
        id: 234, average: 95.60, name: Sally
        id: 345, average: 96.70, name: Billy
value returned: 3
17 - exam_write_students_to_file
        filename: (null)
Error: filename is NULL
value returned: 1
17 - exam_write_students_to_file
        filename: asdf.txt
value returned: 0
18 - exam_read_students_from_file
        filename: asdf.txt
        123 94.500000 John
        234 95.599998 Sally
        345 96.699997 Billy
value returned: 0
19 - exam_display_students_from_list
id: 11, average: 90.11, name: Sam
id: 22, average: 90.22, name: Jack
id: 33, average: 90.33, name: Lisa
value returned: 0
20 - exam_return_total_lines
        main.c:         lines: 253, chars: 6881
        exam/exam.h:    lines: 158, chars: 4059
        exam/exam.c:    lines: 398, chars: 10282
Total lines: 809
#include <stdio.h>
#include<stdint.h>
void exam_hello_world(void){
printf("1 - exam_hello_world\n");
printf("CSCI 112 Final\n");
printf("Code by Norman McEntire\n");
}
int exam_cmd_line_args(int argc, char *argv[]){
int i;
printf("\n2 - exam_cmd_line_args");
printf("argc:%d",argc);
// for(i=0;i<argc;i++){
// printf("argv[%d]:%c",i,argv[i]);
// }
return argc;
}
int exam_signed_integer_data_types(void){
char c;
int i;
short s;
long l;
printf("3 - exam_signed_integer_data_types\n");
printf("type size\n");
printf("---- ----\n");
printf("char %ld \n",sizeof(c));
printf("short %ld \n",sizeof(s));
printf("int %ld \n",sizeof(i));
printf("long %ld \n",sizeof(l));
return 4;
}
int exam_unsigned_integer_data_types(void){
unsigned char c;
unsigned int i;
unsigned short s;
unsigned long l;
printf("\n4 - exam_unsigned_integer_data_types");
printf("\ntype size\n");
printf("---- ----\n");
printf("unsigned char %ld \n",sizeof(c));
printf("unsigned short %ld \n",sizeof(s));
printf("unsigned int %ld \n",sizeof(i));
printf("unsigned long %ld \n",sizeof(l));
return 2;
}
int exam_stdint_integer_data_types(void){
int8_t i8;
int16_t i16;
int32_t i32;
printf("\n5 - exam_stdint_integer_data_types");
printf("\ntype size\n");
printf("---- ----\n");
printf("uint8_t %ld \n",sizeof(i8));
printf("uint16_t %ld \n",sizeof(i16));
printf("uint32_t %ld \n",sizeof(i32));
return 3;
}
int exam_floating_data_types(void){
float f;
double d;
printf("\n6 - exam_floating_data_types");
printf("\ntype size");
printf("\n---- ----");
printf("\nfloat %ld \n",sizeof(f));
printf("double %ld \n",sizeof(d));
// float 4
// double 8
return 2;
}
int exam_sum(int n1, int n2, int n3){
printf("\n7 - exam_sum");
printf("\nn1: %d n2: %d n3: %d",n1,n2,n3);
return n1+n2+n3;
}
int exam_compare(int n1, int n2){
printf("8 - exam_compare");
printf("\nn1: %d n2: %d",n1,n2);
if(n1<n2)
return -1;
else if(n1==n2)
return 0;
else
return 1;
}
int exam_for(int n1, int n2){
int i,sum=0;
printf("\n9 - exam_for");
printf("\nn1: %d n2: %d",n1,n2);
for(i=n1;i<=n2;i++)
sum+=i;
return sum;
}
int exam_while(int n1, int n2){
int sum=0;
printf("\n10 - exam_while");
printf("\nn1: %d n2: %d",n1,n2);
while(n1<=n2){
sum+=n1;
++n1;
}
return sum;
}
int exam_do_while(int n1, int n2){
int sum=0;
printf("\n11 - exam_do_while");
printf("\nn1: %d n2: %d",n1,n2);
do{
sum+=n1;
++n1;
}
while(n1<=n2);
return sum;
}
int main(void) {
int fun3,fun4,fun5,fun6,fun7,fun8,fun9,fun10,fun11;
exam_hello_world();
fun3=exam_signed_integer_data_types();
printf("value returned:%d",fun3);
fun4=exam_unsigned_integer_data_types();
printf("value returned:%d",fun4);
fun5=exam_stdint_integer_data_types();
printf("value returned:%d",fun5);
fun6 = exam_floating_data_types();
printf("value returned:%d",fun6);
fun7 = exam_sum(10,20,30);
printf("\nvalue returned:%d\n",fun7);
fun8 = exam_compare(-10,20);
printf("\nvalue returned:%d\n",fun8);
fun8 = exam_compare(10,10);
printf("\nvalue returned:%d\n",fun8);
fun8 = exam_compare(20,10);
printf("\nvalue returned:%d\n",fun8);
fun9 = exam_for(10,20);
printf("\nvalue returned:%d\n",fun9);
fun10 = exam_while(10,20);
printf("\nvalue returned:%d\n",fun10);
fun11 = exam_do_while(10,20);
printf("\nvalue returned:%d\n",fun11);
return 0;
}