Advertisement
ppupil2

Q10-PRF192-PE-31.03

Mar 31st, 2020
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 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, i, sum;
  11.     int b[15], count;
  12.    
  13.     scanf("%d", &a);
  14.    
  15.     count = 0; i = 0;
  16.     while (a>0) {
  17.         b[i] = a%10;
  18.         count++;
  19.         a /= 10;
  20.     }
  21.    
  22.     sum = 0;
  23.     for (int i = count-1; i>=0; i-=2) {
  24.         sum +=i;
  25.     }
  26.  
  27.  
  28.   // Fixed Do not edit anything here.
  29.   printf("\nOUTPUT:\n");
  30.   //@STUDENT: WRITE YOUR OUTPUT HERE:
  31.     printf("%d",sum);
  32.  
  33.  
  34.  
  35.   //--FIXED PART - DO NOT EDIT ANY THINGS HERE
  36.   printf("\n");
  37.   system ("pause");
  38.   return(0);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement