answersLogoWhite

0


Best Answer

Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the program to find sum of n natural numbers in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the c plus plus program for printing sum to n natural numbers?

main() { int i, n, sum=0; cout<<"Enter the limit"; cin>>n; for(i=0;i<=n;i++) sum=sum+i; cout<<"sum of "<<n<<" natural numbers ="<<sum; getch(); }


Every natural numbers is a whole numbers?

Yes, the set of whole number is all of the natural numbers, plus zero.


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


Why does every integer have an opposite?

The numbers 1,2,3,... etc are called natural numbers or counting numbers. Integers are the natural numbers plus zero plus the negative ( or opposite ) natural numbers. Why do we need negative natural numbers ? For one thing x + 1 = 0 is an equation whose solution is x = -1. We could not solve this equation if we did not have negative integers. So over history these negative numbers came about as a way to solve certain math problems. The numbers 1,2,3,... etc are called natural numbers or counting numbers. Integers are the natural numbers plus zero plus the negative ( or opposite ) natural numbers. Why do we need negative natural numbers ? For one thing x + 1 = 0 is an equation whose solution is x = -1. We could not solve this equation if we did not have negative integers. So over history these negative numbers came about as a way to solve certain math problems.


What is P plus P plus N in prime numbers?

It would always be a natural number.


C plus plus program to find all even numbers between 100 and 150 using for loop?

#includeint main(){int i;for(i=2;i


Write a C plus plus program to find out the square of first 10 numbers?

#include<iostream> int main() { int i=0; while(i++<10) std::cout<<i*i<<std::endl; }


What natural numbers are whole numbers?

The set of counting numbers is the positive integers. The set of whole numbers is the positive integers plus zero. The term "natural numbers" has been used interchangeably with both of those sets.


Write a c plus plus program to find the largest among three numbers using ternary operators?

R = (A > B && A > C) ? A : (B > C) ? B : C; // parentheses not necessary - for clarity only


Write a c plus plus programs to find the sum of first n natural number and to display the number of terms edit?

Your question is not clear but i can write a program to find the sum of n natural numbers. #include<iostream.h> #include<conio.h> int main() { long int res=0; int last; cout<<"enter the last number."; cin>>last; for(int i=0;i<=last;i++) res=res+i; cout<<"Result is "<<res<<endl; return 0; }


Write a C plus plus program and flow chart to find the largest of the 3 numbers?

To find the largest of three numbers, first find the largest of two numbers: int max (int x, int y) { return x<y?y:x; } Now you can use this one function to find the largest of three numbers: int max (int x, int y, int z) { return max (max (x, y), z); }