[1-1]

#include<stdio.h>

main()

{

 int n_apple,n_orange,w_apple,w_orange,total;

 

 n_apple=6;

 n_orange=2;

 w_apple=12.2;

 w_orange=9.7;

 total=n_apple*w_apple+n_orange*w_orange;

 printf("Total weight = %d\n",total);

}

 

[1-2]

#include<stdio.h>

main()

{

 int n_apple,n_orange;

 float w_apple,w_orange,total;

 

 n_apple=6;

 n_orange=2;

 w_apple=12.2;

 w_orange=9.7;

 total=(float)n_apple*w_apple+(float)n_orange*w_orange;

 printf("Total weight = %f\n",total);

}

 

[1-3]

#include<stdio.h>

float total_weight(int,int,float,float);

 

main()

{

 int n_apple,n_orange;

 float w_apple,w_orange,total;

 

 n_apple=6;

 n_orange=2;

 w_apple=12.2;

 w_orange=9.7;

 total=total_weight(n_apple,n_orange,w_apple,w_orange);

 printf("Total weight = %f\n",total);

}

 

float total_weight(int na,int no,float wa,float wo)

{

 float t;

 

 t=(float)na*wa+(float)no*wo;

 return(t);

}