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 syntax error?
what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?
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............
void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis
difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?
which typw of errors ? & how to solve it ?
#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }
printy(a=3,a=2)