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 |
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
difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?
What is the code for following o/p * * * * * * * * * * * * * * * *
Write a c-programe that input one number of four digits and find digits sum?
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.)
write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;
void main() { int i=5; printf("%d",i+++++i); }
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 ?
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
#include<>stdio.h> #include<>conio.h> { printf("hello"); void main() getch(); } what the out put of this program and why ......plz clear my answer
How to develop a program using C language to convert 8-bit binary values to decimals. TQ