CSCD 255 HW 2. No string (char arrays) or any other kinds of array variables are allowed

Similar documents
LAB 11: METHODS. CPCS The Lab Note Lab 11 Page 1. Statement Purpose:

Assignments 3 & 4. COMP248/Winter Assignment 3 & 4 Page 1 of 7

11.3 Function Prototypes

CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions. User Defined Functions

Sequential Search (Searching Supplement: 1-2)

EECS2031 Winter Software Tools. Assignment 1 (15%): Shell Programming

CS1100 Introduction to Programming

CSCI 111 First Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, October 18, 2017

Software and Programming 1

ECE15: Lab #2. Problem 1. University of California San Diego

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

int x = 5; double y = 3; // Integer division rounds the result down to the nearest whole number. cout << "1a: " << x / 3 << endl; //1

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

Loops / Repetition Statements

LAB 5: REPETITION STRUCTURE(LOOP)

! definite loop: A loop that executes a known number of times. " The for loops we have seen so far are definite loops. ! We often use language like

Control Statements Loops

(First is used here)

Lab 2: Structured Program Development in C

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++

In this lab, you will learn more about selection statements. You will get familiar to

LAB 12: ARRAYS (ONE DIMINSION)

Note: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be.

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include

Programming Assignment #2

Learning Objectives: General Description: DONE DONE Structure Chart

Project 3: RPN Calculator

COL100 Lab 2. I semester Week 2, Open the web-browser and visit the page and visit the COL100 course page.

Loops (while and for)

Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F

Algebra 1. Standard 11 Operations of Expressions. Categories Combining Expressions Multiply Expressions Multiple Operations Function Knowledge

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Carleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012

Lesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014

LAB 4.1 Relational Operators and the if Statement

Introduction to Programming in Turing. Input, Output, and Variables

EECE.2160: ECE Application Programming Spring 2018 Programming Assignment #6: Using Arrays to Count Letters in Text Due Wednesday, 4/4/18, 11:59:59 PM

by the evening of Tuesday, Feb 6

Programming in C++ 5. Integral data types

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

Building Java Programs

Lab ACN : C++ Programming Exercises

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

Variables, Data Types, and Arithmetic Expressions Learning Objectives:

Loops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

Programming Assignment 2

Special Section: Building Your Own Compiler

Lab 1 Introduction to UNIX and C

Pattern Maker Lab. 1 Preliminaries. 1.1 Writing a Python program

Project 5 Handling Bit Arrays and Pointers in C

CS 211 Programming Practicum Fall 2018

CSCI 111 First Midterm Exam Spring Solutions 09.05am 09.55am, Wednesday, March 14, 2018

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

Lab 9 Loops, Debugging

CS1110 Lab 6 (Mar 17-18, 2015)

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

Ch.5. Loops. (a.k.a. repetition or iteration)

Combinatorics Prof. Dr. L. Sunil Chandran Department of Computer Science and Automation Indian Institute of Science, Bangalore

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

Prerequisites: Read all chapters through Chapter 4 in the textbook before attempting this lab. Read through this entire assignment before you begin.

CISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts)

Lab Session # 5 Arrays. ALQUDS University Department of Computer Engineering

EL2310 Scientific Programming LAB2: C lab session. Patric Jensfelt, Andrzej Pronobis

ECE2049 HW #1-- C programming and Binary Number Representations (DUE Friday 8/31/2018 At the BEGINNING of class)

assertion: A statement that is either true or false.

QUIZ: What is the output of this MATLAB code? >> A = [2,4,10,13;16,3,7,18; 8,4,9,25;3,12,15,17]; >> length(a) >> size(a) >> B = A(2:3, 1:3) >> B(5)

Lecture 13 Bit Operations

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

Programming Languages ML Programming Project Due 9/28/2001, 5:00 p.m.

Loops / Repetition Statements

CS 2316 Pair 1: Homework 3 Enigma Fun Due: Wednesday, February 1st, before 11:55 PM Out of 100 points

Claremont McKenna College Computer Science

Tutorial 7. Number Colour Black Brown Red Orange Yellow Green Blue Violet Gray White

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

: Intro Programming for Scientists and Engineers Assignment 7: Classes

Chapter 6. Repetition Statements. Animated Version The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Programming Assignment 5: Implementing a Reliable Transport Protocol

Switching Circuits and Logic Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Arrays. Here is the generic syntax for an array declaration:

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related?

Evil Hangman Project

Lab 4-2 Create an Activity Diagram

Assignment 4 - Vectors, Menus, & Creatures!

;; definition of function, fun, that adds 7 to the input (define fun (lambda (x) (+ x 7)))

BOOLEAN EXPRESSIONS CONTROL FLOW (IF-ELSE) INPUT/OUTPUT. Problem Solving with Computers-I

Up Diagonal. Right. Question No. 1 (60 points)

The American University in Cairo Computer Science & Engineering Department CSCE Dr. KHALIL Exam II Spring 2010

Project Identity Shampoo-Conditioner Identification Device/ Medicine Reminder Week 2: 1/28/07-2/3/07 Karla Sittnick

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

SIMPLE PROGRAMMING. The 10 Minute Guide to Bitwise Operators

CSCE 110: Programming I

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I

5. Selection: If and Switch Controls

Computer Networks. Project 2. Project Assigned: November 14 Checkpoint: November 21 12:01 AM Due: December 04 12:01 AM. Networks - Project 2 1

DECISION CONTROL AND LOOPING STATEMENTS

Computer Programming. Decision Making (2) Loops

C++ for Everyone, 2e, Cay Horstmann, Copyright 2012 John Wiley and Sons, Inc. All rights reserved. Using a Debugger WE5.

CS 202 Data Structures (Spring 2007)

Transcription:

CSCD 255 HW 2 Design a program called cscd255hw2.c which reads in a strictly positive integer (1 or greater) from the user. The user will then be prompted with a menu of choices (this menu should be repetitively displayed until the user chooses to quit): Your menu will include these choices 2. Print the number of odd digits, even digits and zeros in the integer (inclusive) PROGRAM PARTICULARS: When the program starts up, ask the user for a positive integer. After the user enters a positive integer, display the above menu. Remember the user can choose to do #2, #3, and #4 on the same number; meaning, once you have the number from the user do not make the user enter a new number each time. The user can keep the same number until the user selects option 1. I have added a sample output of what the program should execute like. (See Below) There must be error checking on the input integer: if it is negative or 0, the program will print an error message and re-prompt. This process will continue until valid input is entered. You may assume an integer of some form will be entered by the user. There must be error checking on the menu choice entered: if the user enters a choice not on the menu, the program will print an error message, re-display the menu and reprompt. This process will continue until valid input is entered. No string (char arrays) or any other kinds of array variables are allowed No built-in functions for integer manipulation are allowed. You may assume that no integer entered will be greater than the maximum integer size for type int.

HINTS: First, solve the primary problems one at a time, testing each one separately. (Make sure that your algorithm works for single-digit numbers). Solve the input and error checking problems once the others are solved and tested. You will want to have this finished or close to finished by Wednesday, 11 Feb. Lab 5 (due that day) uses a mandated main, with all of the logic of this problem moved into user-defined functions. TURN IN: A zip file (hopefully you understand the naming scheme) containing cscd255hw2.c cscd255hw2out.txt GET STARTED ASAP SAMPLE OUTPUT: Welcome to Integer Fun. Please enter a positive integer --> -12 I am sorry that is not a positive integer. Please enter a positive integer --> 120 Choice --> -6

I am sorry that is an invalid menu choice. Please try again Choice --> 2 Your results are: odd - 1 even - 1 zero(s) - 1 4.Print the number in reverse order Choice --> 4 The number 120 in reverse order is 021

4.Print the number in reverse order Choice --> 1 Please enter a positive integer --> 10 Choice --> 2 Your results are: odd - 1 even - 0 zero(s) - 1 Please select from the following menu choices: 1: Enter a new number 2: Print the number of odd, even, and zero digits in the integer.

3: Print the prime numbers betwen 2 and the integer. 4: Print the number in reverse order. 5: Quit the program. Which choice do you wish? 3 2 is prime 3 is prime 5 is prime 7 is prime Choice --> 5 Thank you and have a nice day Due date and time: Midnight 13 February