Question: 1) using a while-loop,write the C code to compute and display the following sum 3/.3+5/.3+7/.3+9/.3+11/.3 main(){ //declaring variables int i=3; float a=0.3,sum=0.0; //using while loop
1) using a while-loop,write the C code to compute and display the following sum
3/.3+5/.3+7/.3+9/.3+11/.3
main(){ //declaring variables int i=3; float a=0.3,sum=0.0; //using while loop findin the sum while(i<=11){ sum=sum+((float)i/a); i=i+2; } //displayin the result sum printf("The total sum is: %.2f ",sum); return 0; }
2. write the code using a comperable for-loop to solve the same problem.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
