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..

total=0;
k=1;
do
{
total=total+k*k*k;
k++;
}while(k<=n)

 Is This Answer Correct ? 27 Yes 32 No

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

#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 9 No

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

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

 Is This Answer Correct ? 4 Yes 17 No

More C C++ Errors Interview Questions

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

What are the different types of errors in C and when they occur?

Write down the difference between c. Loop and goto statement d. (!0) and (!1) e. (1= =! 1) and (1!=1) f. NULL and !NULL

How to reverse a linked list without using array & -1? Thank you.

Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.

Display this kind of output on screen. 1 0 1 1 0 1 3. Display this kind of output on screen. 1 1 0 1 0 1 4. Display this kind of output on screen. 1 1 0 1 0 1 5.Display this kind of output on screen. 1 2 3 4 5 6 7 8 9 10

what is exceptions?

what are the techniques for reducing the fragility of a memory bug?

how tally is useful?

WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }

what is the large sustained error signal that eventually cause the controller output to drive to its limit

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

Categories
• C C++ Errors (70)
• DotNet Errors (17)
• Database Errors (16445)
• Scripts Errors (102)