Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please show the above program for a C/C++ format on a PC Write a program that: D

ID: 3801553 • Letter: P

Question

Please show the above program for a C/C++ format on a PC

Write a program that: Define a structure "Test" to house a the test number as an integer and test score as a float. Prompt the user for the number of tests they have already had and use the number to dynamically allocate the needed memory to store the information about all these tests under the name myTests. If memory allocation is successful, prompt the user for the test number and then the score for the test and store these in the appropriate structure element. When the user is done, print the list of tests and scores. A typical user interaction i shown below: How many Tests do you have? 3 Enter Test number: 1 Enter your score: 44 Enter Test number: 2 Enter your score: 87 Enter Test number: 3 Enter your score: 99 Score for Test 1 = 44.000000 Score for Test 2 = 87.000000 Score for Test 3 = 99.000000

Explanation / Answer

#include<stdio.h>

#include<conio.h>

struct test

{

int number;

float score;

};

void main()

{

struct test *mytests;

int noOfTests;

printf("how many tests do you have ?");

scanf("%d",&noOfTests);

mytests=(struct test*) malloc (noOfTests * sizeof(struct test));

for(int i=0;i<noOfTests;++i)

{

printf(" Enter test number");

scanf("%d",&(mytests+i)->number);

printf(" Enter your score");

scanf("%f",&(mytests+i)->score);

}

for(int i=0;i<noOfTests;++i)

{

printf(" score for test %d = %f",(mytests+i)->number,(mytests+i)->score);

}

}