Advertisement
ppupil2

Q2-PRF192-PE-trial

Mar 30th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6.  
  7. int main() {
  8.   system("cls");
  9.   //INPUT - @STUDENT:ADD YOUR CODE FOR INPUT HERE:
  10.     int a, sum, count;
  11.    
  12.     scanf("%d", &a);
  13.     sum = 0; count = 0;
  14.     for (int i = a; i>0; i--) {
  15.         if (i%2 == 0) {
  16.             sum += i;
  17.             count++;
  18.         }
  19.         if (count == 3) break; 
  20.     }
  21.  
  22.   // Fixed Do not edit anything here.
  23.   printf("\nOUTPUT:\n");
  24.   //@STUDENT: WRITE YOUR OUTPUT HERE:
  25.     printf("%d", sum);
  26.  
  27.   //--FIXED PART - DO NOT EDIT ANY THINGS HERE
  28.   printf("\n");
  29.   system ("pause");
  30.   return(0);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement