Computer Science, asked by Preethisanga9, 10 months ago

Write a pseudo-code to find the sum of numbers divisible by 4.The pseudo-code must allow the user to accept a number and add it to the sum if it is divisible by 4. It should continue accepting numbers as long as the user wants to provide an input and should display the final sum.

Answers

Answered by qwtiger
4

Answer:

#include <cmath>  

#include <iostream>  

using namespace std;  

 

// Returns sum of n digit numbers  

// divisible by 'number'  

int totalSumDivisibleByNum(int n, int number)  

{  

   // compute the first and last term  

   int firstnum = pow(10, n - 1);  

   int lastnum = pow(10, n);  

     

   // sum of number which having  

   // n digit and divisible by number  

   int sum = 0;  

   for (int i = firstnum; i < lastnum; i++)  

       if (i % number == 0)  

           sum += i;  

   return sum;  

}  

 

// Driver code  

int main()  

{  

   int n = 3, num = 7;  

   cout << totalSumDivisibleByNum(n, num) << "\n";  

   return 0;  

}

Answered by saumyarupsen7
2

Explanation:

Input : n = 2, number = 7

Output : 728

There are nine n digit numbers that

are divisible by 7. Numbers are 14+

21 + 28 + 35 + 42 + 49 + .... + 97.

Input : n = 3, number = 7

Output : 70336

Input : n = 3, number = 4

Output : 124200

please make it as the brainliest one

Similar questions