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 |
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 ?
Write a c-programe that input one number of four digits and find digits sum?
what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?
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,
Answering Yes or No in C++...using only stdio.h and conio.h..........help me please...? here's must be the output of the program: Screen A Exam No. items Score 1 20 20 2 35 35 Another Entry? [Y] or [N] : Screen B: Record No. Student's Name: 1 Fernando Torres 2 Chuck Norris Note: if you press Y, the program must repeat the procedure in screen A, then if N, the program must proceed to the screen B....Please Help me out............
Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .
How to develop a program using C language to convert 8-bit binary values to decimals. TQ
What are the different types of errors in C and when they occur?
how to convert decimal to hexadecimal without using arrays just loops
wap for bubble sort
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
To generate the series 1+3+5+7+... using C program