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

Answer / sachin

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

 Is This Answer Correct ? 4 Yes 17 No

More C C++ Errors Interview Questions

which typw of errors ? & how to solve it ?

What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0

#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }

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 .

UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....

write a profram for selection sort whats the error in it?

wap for bubble sort

who was the present cheif governor of reserve bank of india

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

char* f() return "hello:"; void main() {char *str=f(); }

loop1: { x=i<n?(i++):0; printf("%d",i); exit(x); continue; } Error- misplaced continue. Doubt-1.will the exit(x) be executed for all values of x 2.will this statement go out of the program.

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

Categories