Advertisement
NB52053

CGPA_CALCULATOR

Dec 8th, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. int i,n,sum=0,y[100];
  7. float x[100],result;
  8.  
  9. printf("How many subjects: ");
  10. scanf("%d",&n);
  11.  
  12.  
  13. for(i=0; i<n; i++)
  14. {
  15. printf("Enter obtained GPA of subject #%d: ",i+1);
  16. scanf("%f",&x[i]);
  17. printf("\nCredit: ");
  18. scanf("%d",&y[i]);
  19. printf("\n");
  20. }
  21.  
  22. for(i=0; i<n; i++)
  23. {
  24. sum = sum + y[i];
  25. result = result + x[i]*y[i];
  26. }
  27.  
  28. printf("\n\nResult is = %.2f\n\n",result/sum);
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement