(1+2+3.....n) Sum of n natural numbers, (1^2 + 2^2+3^2 ...... n^2)Sum square of n natural numbers, Sum cube of n natural numbers program in C language .
Natural numbers program in c language
How to make (1+2+3.....n) Sum of n natural numbers, (1^2 + 2^2+3^2 ...... n^2)Sum square of n natural numbers, Sum cube of n natural numbers program in C language. Then today we will know about it through this program ...
Sum of n natural numbers
The Sum of n natural number formula are 1+2+3+....n = n(n+1)/2=(n^2+n)/2. The math.h header file is used in this program because the pow() function is defined in this header file. The function pow() syntax is double pow(double a , double b). The double is a data type in c language and it's also defined as %lf for input. In this program add= (k+x)/2 where are k=n^2 ,x=n.
Sum cube of n natural numbers :
The Sum cube of n natural number formula is 13+23+33 +…..n3 = [n(n+1)/2]2 or =[(n2 +n)/2]2.In this program add= pow(q,y); y=2, q = (k+x)/2,and[{ x=n,k=n2 }].
Comments
Post a Comment