Skip to content

Commit

Permalink
Update gfg_potd_10oct_2024.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavm0504 authored Oct 24, 2024
1 parent 4db3c42 commit c68c1bc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions october_2024/gfg_potd_10oct_2024.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
// C++ program to compute sum of digits in
// number.
#include <bits/stdc++.h>
using namespace std;

/* Function to get sum of digits */
class gfg {
class addSum {
public:
int getSum(int n)
{
int sum = 0;
int total = 0;
while (n != 0) {
sum = sum + n % 10;
total = total + n % 10;
n = n / 10;
}
return sum;
return total;
}
};

// Driver code
int main()
{
gfg g;
addSum g;
int n = 687;

// Function call
cout << g.getSum(n);
return 0;
}
// This code is contributed by Soumik

0 comments on commit c68c1bc

Please sign in to comment.