Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

post sample code in two versions: for loop and while loop. Add one line comment to explain what the code is doing. Code using for

post sample code in two versions: for loop and while loop. Add one line comment to explain what the code is doing. Code using for loops (and while) is a great place to practice compound assignments. Here is an example: // factorial of n -- assuming all vars are declared int, n has been input and is >=0 tot=1 for (int i=n; i>0; i--){ tot*=i; } printf(factorial of %d is %d , n,tot); // using while i=n; tot=1 while (i >0) { tot*=i; i--; } printf(factorial of %d is %d , n,tot); // there's one difference between the two codes; what is it?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions