this program functioned as taking the average of each 3 test and categorize it to "low", "medium", "high". the "input" function is used to collect data from a user . "deter" function was to calculate the average and to categorize it. "display" function was to show all the results. In this program I can pass float type data but why I can't pass with string type data. Can someone help me pls?.
#include <stdio.h>
void input ( float*, float*, float* );
void deter (float , float ,float ,float*,char* cate);
void display (float, float, float, float, char);
int main ()
{
float t1_in, t2_in, t3_in, average;
char category[10];
input (&t1_in,&t2_in,&t3_in);
deter(t1_in,t2_in,t3_in,&average,&category);
display(t1_in, t2_in, t3_in, average, category);
}
void input ( float* t1, float* t2, float* t3)
{
printf ("Enter Test 1 >> ");
scanf ("%f",t1);
printf ("Enter Test 2 >> ");
scanf ("%f",t2);
printf ("Enter Test 3 >> ");
scanf ("%f",t3);
}
void deter (float tt1_det, float tt2_det,float tt3_det,float* avg,char* cate)
{
*avg = (tt1_det+tt2_det+tt3_det)/3.0;
if(*avg<2.0)
{
*cate="slow";
}
else if(*avg>=2.0 && *avg<=4.0)
{
*cate="Medium";
}
else if( *avg>4.0)
{
*cate="High";
}
}
void display (float tt1, float tt2,float tt3,float avrg,char ct)
{
printf ("\nTest 1 is %.2f ",tt1);
printf ("\nTest 2 is %.2f ",tt2);
printf ("\nTest 3 is %.2f ",tt3);
printf ("\nAverage >> %.2f",avrg);
printf("\nCategory >> %10s",ct);
}
here is my out put
Enter Test 1 >> 1
Enter Test 2 >> 2
Enter Test 3 >> 3
Test 1 is 1.00
Test 2 is 2.00
Test 3 is 3.00
Average >> 2.00
Process returned -1073741819 (0xC0000005) execution time : 1.478 s
Press any key to continue.
Aucun commentaire:
Enregistrer un commentaire