Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int i,n,sum=0,y[100];
- float x[100],result;
- printf("How many subjects: ");
- scanf("%d",&n);
- for(i=0; i<n; i++)
- {
- printf("Enter obtained GPA of subject #%d: ",i+1);
- scanf("%f",&x[i]);
- printf("\nCredit: ");
- scanf("%d",&y[i]);
- printf("\n");
- }
- for(i=0; i<n; i++)
- {
- sum = sum + y[i];
- result = result + x[i]*y[i];
- }
- printf("\n\nResult is = %.2f\n\n",result/sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement