#include
#include
using std::cin;
using std::cout;
using std::endl;
using std::string
int main()
{
const int numberOfdigits = 5;
string myNumber = "0";
char myNumberChar[numberOfdigits] = {0};
cout << endl << "Enter 4 digit integer: ";
cin >> myNumber;
int sumOfDigits = 0;
int temp = 0;
for (int arrayIndex = 0; arrayIndex < (numberOfdigits - 1); arrayIndex++)
{
temp = atoi(&myNumber.substr(arrayIndex, 1)[0]);
sumOfDigits += temp;
}
cout << endl << "Sum of 4 digits is: " << sumOfDigits << endl;
system("PAUSE");
return 0;
}
Chat with our AI personalities
Peterson Number:145 = 1! + 4! + 5!number=sum of (factorials of digits)
#include <stdio.h> #include<conio.h> void main () { int a,r,n,sum=0; clrscr(); printf("enter the number"); scanf("%d",& n); c=n while (n!=0) { a=n%10; n=n/10; sum=sum*a+a } printf("the reverse is %d \n",sum); if(c==sum) printf("\n the given number is palindrome"); else printf("\n the given number is not a palindrome"); getch(); }
The sum of is the total of everything being summed; the sum total. Thus the sum of a, b and c is therefore a + b + c.
--THE SUM OF TWO NUMBERS: declare a number(2); b number(2); c number(2); begin a:=&a; b:=&b; c:=a+b; dbms_output.put_line(a ' + 'b' = 'c); end;
6 + c