lab3 - Lab Assignment 3 CSE 1310 2011-09-13 15:11:19 CSE...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lab Assignment 3 CSE 1310 2011-09-13 15:11:19 CSE 1310 – Laboratory Assignment #3 Week of September 28, 2009 name: Darin Brezeale course: CSE 1310 assignment: lab 3a date: September 21, 2009 purpose: 1) Practice using loops. 2) Practice using conditionals. description: Write a program that for the integers in the range 2 to 100, counts how many are evenly divisible by 2, 3, 5, or 7. The program should print the counts when done. sample output: $ ./lab3a There are 50 integers evenly divisible by 2 There are 33 integers evenly divisible by 3 There are 20 integers evenly divisible by 5 There are 14 integers evenly divisible by 7 CHECKPOINT: Show your source code to the TA. CHECKPOINT: Let the TA run your program. Solution: #include <stdio.h> int main (void) { int count1 = 0; int count2 = 0; int count3=0; int count4 = 0; int i; for(i =2; i <= 100; i++) { if((i%2) == 0) count1++; if((i%3) == 0) count2++; Page 1 of 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lab Assignment 3 CSE 1310 2011-09-13 15:11:19 if((i%5) == 0) count3++; if((i%7) == 0) count4++; } printf("There are %d integers evenly divisible by 2\n", count1);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/12/2011 for the course JAVA 2312 taught by Professor Darinbrezeale during the Spring '11 term at University of Texas at Austin.

Page1 / 6

lab3 - Lab Assignment 3 CSE 1310 2011-09-13 15:11:19 CSE...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online