Exam with Solution - Introduction to Computing Java | CSC 116, Study notes of Java Programming

Material Type: Notes; Class: Introduction to Computing - Java; Subject: Computer Science; University: North Carolina State University; Term: Spring 2005;

Typology: Study notes

Pre 2010

Uploaded on 03/10/2009

koofers-user-xgw
koofers-user-xgw 🇺🇸

5

(1)

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1

 !"
#$%%&''"((%)&&(%)*



#$')%+,#-"%,./0/0/01/0/0
 !
"#$%%&'
(
)

"$*&'
(
)
&$%+,*+!,!

Partial preview of the text

Download Exam with Solution - Introduction to Computing Java | CSC 116 and more Study notes Java Programming in PDF only on Docsity!

CSC 116 — 002 In-class Exercise #3 Name: __ Solution Unity ID: Lab: 1. What is the difference between a while loop and a do-while loop? Awhile loop checks the Boolean expression before executing the loop body. The do-while loop will execute the loop at least once before checking the condition. 2. Write a for loop that calculates 7!. Remember that x! = (x)(x — 1)(x — 2) ... (2)(1) int factorial = 1; //needs to be 1 otherwise multiply by 0 for(int i = 1; i 7; itt) { factorial *= i; } int factorial = 1; for(int i =7; i 1; i-) { factorial *= i; } Extra Credit: What is 7!? 5040