This is a c programming course (not advanced). I have attempted to do this and f
ID: 3581964 • Letter: T
Question
This is a c programming course (not advanced). I have attempted to do this and failed completely. I can upload my attempt to if it helps, but i dont imagine it can help. Only perhaps to point my mistakes. Which are guaranteed and given. Can anyone help?
Your result for studentDB.c Program should be correct. To test: For the following inputs Alex Taylor "s4567", "Inf", f 23 Oliver "Ford", "s5678", "Eng", 'm', 18 "Daniel Thomas s6789 Inf 'm', 20. The result printed out by your 'main' should be: Alex Taylor, s 4567, Inf, f, 23 Extra: can you alter findoldest to take a length as well as the array, instead of assuming length 6? Extra: can you write a function called pretty to take an item of type student-t and print out the details of that student in a pretty fashion'? Submit your program with submit cp lab7 studentDB.c Stage C Running Club database and functions The starting point for this stage of the lab is the file running.c, which you may download from the course webpage. This file contains a suite of type declarations, as well as the function prototypes for this question (and the code for some helper functions). The first type declaration is a structured type runtime-t to store running results in hours, minutes and seconds. runner-t is another structured type containing the fields name, runid (unique id of the runner, guaranteed to be a positive integer), and two fields pb (personal best) and recent (most recent) of type runtime t. The structured type runclub-t consists of an array of size MAXRUNNERS of type runner-t, together with a field total which we will use to maintain a count of the current number of runners in the running club. Below are details of the structured data types: typedef struct int hr: int min int sec runtime-t typedef struct char name [30]; int runid; runtime-t pb; runtime-t recent t runner t typedef struct t int total runner-t runners DMAXRUNNERSJ run club tExplanation / Answer
/* Student Data Base*/
#include <stdio.h>
struct studentDB
{
char firstname[50];
char lastname[50];
int rollno;
char stream[50];
char gender[10];
int age;
} s[10];
int main()
{
int i;
printf("Enter students Data Base: ");
// storing information
for(i=0; i<10; ++i)
{
s[i].rollno = i+1;
printf(" For roll number%d, ",s[i].rollno);
printf("Enter First name: ");
scanf("%s",s[i].firstname);
printf("Enter Last name: ");
scanf("%s",s[i].lastname);
printf("Enter Stream: ");
scanf("%s",s[i].stream);
printf("Enter gender: ");
scanf("%s",s[i].gender);
printf("Enter age: ");
scanf("%d",s[i].age);
printf(" ");
}
printf("Displaying Information: ");
// displaying information
for(i=0; i<10; ++i)
{
s[i].rollno = i+1;
printf(" roll number%d, ",s[i].rollno);
printf("First name: ");
scanf("%s",s[i].firstname);
printf("Last name: ");
scanf("%s",s[i].lastname);
printf("Stream: ");
scanf("%s",s[i].stream);
printf("gender: ");
scanf("%s",s[i].gender);
printf("age: ");
scanf("%d",s[i].age);
printf(" ");
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.