Best Answer

#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;

}

🙏

🤨

😮

Study guides

☆☆

Q: Sum of 4digit of a number in c?

Write your answer...

Submit

Still have questions?

Related questions

4digit number

5295

It is 1,000.

9000

1000

kl

(c+4)/2

The sum and average of a given number is just that number, so there is no need to write a program.

A + b = c

Let `a` be a rational number and `b` be an irrational number,assume that the sum is rational. 1.a +b =c Where a and c are rational and b is irrational. 2.b=c-a Subtracting the same number a from each side. 3.b is irrational c-a is a rational number we arrived at a contradiction. So the sum is an irrational number.

The sum of a rational and an irrational number is always irrational. Here is a brief proof:Let a be a rational number and b be an irrational number, and c = a + b their sum. By way of contradiction, suppose c is also rational. Then we can write b = c - a. But since c and a are both rational, so is their difference, and this means that bis rational as well. But we already said that b is an irrational number. This is a contradiction, and hence the original assumption was false. Namely, the sum c must be an irrational number.

viod main() { int a,b,c; float sum,avg; a=10; b=20; c=30; sum=a+b+c; avg=sum/3; print("\n Avg : "avg); }

Peterson Number:145 = 1! + 4! + 5!number=sum of (factorials of digits)

This only works in Xcode Command Line Tool.#include int main (int argc, const char * argv[]){int sum=0, accum1, accum2;int i, c, n;printf("Enter Number: ");scanf("%d", &n);for(i=1;c

The sum of every odd number is infinite.

Let your sum be a + b = c, where "a" is irrational, "b" is rational, and "c" may be either (that's what we want to find out). In this case, c - b = a. If we assume that c is rational, you would have: a rational number minus a rational number is an irrational number, which can't be true (both addition and subtraction are closed in the set of rational numbers). Therefore, we have a contradiction with the assumption that "c" (the sum in the original equation) is rational.

#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.

J C Sum was born in 1976.

function requestedFunction(a,b,c) { document.write("Largest number:" + Math.max(a,b,c) + "Sum of numbers:" + (a+b+c)) }

it's simple: { int a,b,c,d; printf("enter the numbers"); scanf("%d %d %d" &a &b &c); d=a+b+c; printf("the sum is=%d" d); }

1. start2. initialize counter (c = o)3. initialize sum (sum = 0)4. input n 'number of items for which average is to be calculated'5. input the 1st (2nd, 3rd, ....) number6 increment counter (c = c+1)7. add the last number to sum (sum = sum+n)8. make a decision (is counter = number of items?) yes goto 9 No goto 59. find average (ave = sum/n)10. print result11. end

a = 5;b = 10;c = a + b;System.out.println("The sum is " + c);a = 5;b = 10;c = a + b;System.out.println("The sum is " + c);a = 5;b = 10;c = a + b;System.out.println("The sum is " + c);a = 5;b = 10;c = a + b;System.out.println("The sum is " + c);

If the sum of squares of digits of a number equals to the number itself, then that number is called an aram strong number.

This is the Distributive Law : a x ( b + c) = ab + ac