Answer ALL 3 for 3-5 stars. Problem 1 -- Write an application, main1.c (50 point
ID: 3536368 • Letter: A
Question
Answer ALL 3 for 3-5 stars.
Problem 1 -- Write an application, main1.c (50 points)
create an array of students using the student structure
Dick Chase 031294 Biology Senior
Anne White 052493 Computer Sophomore
Terry Hall 062194 Phyics Freshman
Rick James 110298 Computer Junior
Jim Tolly 090267 Biology Sophomore
Jeff Leeks 042469 Computer Senior
Mike Small 121488 Computer Senior
Lauri Left 021486 Nursing Junior
Cindy Tims 052884 Computer Freshman
search for Seniors and print out their information. print out all Computer major student
use the following structure
#define MAXLEN 25
#define MAXSTUDENTS 15
struct student
{
char name[MAXLEN];
int studentID;
char major[MAXLEN];
char classLevel[MAXLEN];
};
Problem 2 -- write an application that reads in %u201Cn%u201D names and determines
if any two are the same (40 points ).
the main function, main2.c, will read in the names by calling the readLine function
prompt the user to enter at least five names each time a name is entered malloc the space in char *person[MAXNAMES] for the string containing the name.
main3.c will compare the names and print out any two name that are same independent of upper or lower case.
create only one file, main2.c, which will contain two functions main and readLine
int readLine(char name[], int maxChar)
{
int ch;
int i = 0;
while ( (ch = getchar()) !- ' ' )
{
if ( i < maxChar )
name[i++] = ch;
}
name[i] = ''; // terminates string
return i; // returns number of characters stored
} // end readLine
Problem 3 -- write an application that finds the largest and smallest element in an array (10 points)
create main3.c where you shall enter (via the keyboard) 10 numbers and store them in an array
you are to create a function maxMin which is in the file maxMin.c
this function finds the largest and the smallest numbers in the array
this function has 4 parameters %u2013 see the prototype below
you are to print out the largest and smallest numbers of the array in main3.c
prototype maxMin(int a[], int n, int *max, int *min)
You will create 2 files, main2.c and maxMin.c
Explanation / Answer
//main3.c
#include<stdio.h>
#include<conio.h>
#include"maxMin.c"
int main()
{
int i;
int a[10];
int max;
int min;
printf("Enter the 10 numbers ");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
maxMin(a,10,&max,&min);
printf("maximum element =%d ",max);
printf("mainmum element =%d ",min);
system("pause");
}