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 the error in the following code: main() { int i=400,j; j=(i*i)/i; }
2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]
what are the techniques for reducing the fragility of a memory bug?
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?
How to reverse a linked list without using array & -1? Thank you.
Write a c-programe that input one number of four digits and find digits sum?
What is the code for following o/p * * * * * * * * * * * * * * * *
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
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 profram for selection sort whats the error in it?
What are the different types of errors in C and when they occur?
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); }