Given an int variable n that has been initialized to a
positive value and, in addition, int variables k and
total that have already been declared, use a do...while
loop to compute the sum of the cubes of the first n whole
numbers, and store this value in total . Thus if n equals
4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into
total . Use no variables other than n , k , and total .
Answers were Sorted based on User's Feedback
Answer / c.muruganandham
total=0;
k=1;
do
{
total=total+k*k*k;
k++;
}while(k<=n)
| Is This Answer Correct ? | 29 Yes | 35 No |
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int n=3;
int k=1,total=0;
do
{
total=total+(pow(k,3));
k=k+1;
}
while(k<=n);
printf("%d",total);
getch();
return 0;
}
| Is This Answer Correct ? | 3 Yes | 10 No |
what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }
wap for bubble sort
how to convert decimal to binary in c using while loop without using array
50 Answers Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,
what is the large sustained error signal that eventually cause the controller output to drive to its limit
what is run time error?
Why are memory errors hard to debug?
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;
how to convert decimal to hexadecimal without using arrays just loops
I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX
Declaration of Cube Guys please help me.. Is this a right way to declare cube.? If i Compile it. It Says: Cube undeclared what should i do? Please help \thanks in advanced #include<stdio.h> #include<math.h> #include<conio.h> main( ) { float x,y; while(x++<10.0) { printf("Enter Number:"); scanf("%d", &x); y = cube(x); printf("%f %f %f \n", x,pow(x,2),y); cube(x); } { float x; float y; y = x*x*x; } getch(); return (y); }
what is exceptions?
difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?