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

Develop a C code to perform the following tasks: define a floating - point array

ID: 3826423 • Letter: D

Question

Develop a C code to perform the following tasks:

define a floating - point array of size = 14,

input the students grades to each element of the array from keyboard,

print each element of the array

pass the array BY REFERENCE to function function_fail ,

function_fail takes the parameter as POINTER

if some element is smaller than 70, then print the grade

else print "All the students pass!"

1) run the code for the grades as {34,63,56,93,61,89,92,76,67,56,87,68,75,88}

2) run the code for the grades as {81,85,78,89,86,92,94,88,96,91,87,78,89,90}

Explanation / Answer

void function_fail(float *stud_marks)
{
   bool anyElemLessThan70 = false;
   int i;
  
   for(i=0;i<14;i++)
   {
       if(stud_marks[i]<70)
       {
           anyElemLessThan70 = true;
           break; /* If Any element is less than 70, break the loop */
       }
   }
  
   /* Some students have less than grade. Print all grades */
   if(anyElemLessThan70)
   {
       printf(" Some students have less than 70 grade points ");
       printf(" All student grades: ");
       for(i=0;i<14;i++)
           printf("%f ",stud_marks[i]);
   }
  
   /* If you need to print grades of students who only scored less than 70 Add below code instead of above under if statement
   if(anyElemLessThan70)
   {
       printf(" Some students have less than 70 grade points ");
       printf(" Student with less than 70 grades: ");
       for(i=0;i<14;i++)
       {
           if(stud_marks[i]<70)
           printf("%f ",stud_marks[i]);
       }
   }
  
   */
  
   else
       printf(" All the students pass!");
}

void main()
{
   float stud_marks[14];
   int i;
  
   printf(" Enter marks of students in order: ");
  
   for(i=0;i<14;i++)
       scanf("%f",&stud_marks[i]);
  
   printf(" Marks of students Entered : ");

   for(i=0;i<14;i++)
           printf("%f ",stud_marks[i]);
      
   function_fail(stud_marks);  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote