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



Given an int variable n that has been initialized to a positive value and, in addition, int vari..

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

Given an int variable n that has been initialized to a positive value and, in addition, int vari..

Answer / sujeesh krishnan

#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

Given an int variable n that has been initialized to a positive value and, in addition, int vari..

Answer / sachin

total=0;
while(n>=1)
{
total+=n*n*n;
n--;
}

Is This Answer Correct ?    4 Yes 18 No

Post New Answer

More C C++ Errors Interview Questions

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..

32 Answers   College School Exams Tests, CTS, HCL, iGate, SmartData,


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

0 Answers  


difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?

2 Answers   TCS,


What is the code for following o/p * * * * * * * * * * * * * * * *

1 Answers  


Write a c-programe that input one number of four digits and find digits sum?

2 Answers  






How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  


write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;

0 Answers  


void main() { int i=5; printf("%d",i+++++i); }

14 Answers   HCL,


How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?

24 Answers   HCL,


#include<>stdio.h> #include<>conio.h> { printf("hello"); void main() getch(); } what the out put of this program and why ......plz clear my answer

10 Answers   Wipro,


How to develop a program using C language to convert 8-bit binary values to decimals. TQ

1 Answers   Amazon,


Categories