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

Similar documents
The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Dr. Khalil Exam II Fall 2011

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No.

The American University in Cairo Department of Computer Science & Engineeringt CSCI &09 Dr. KHALIL Exam-I Fall 2009

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science. Instructor: Final Exam Fall 2011

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE Instructor: Final Exam Fall 2014

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

Solve only 2 out of 3 questions

LAB 4.1 Relational Operators and the if Statement

CSCE 206: Structured Programming in C++

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

CSCE Practice Midterm. Data Types

University of Michigan EECS 183: Elem. Programming Concepts Fall 2011 Exam 1: Part 1: Form 1. Professors: ML Dorf, Elliot Soloway

CSCE Practice Midterm. Data Types

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

C++ Quick Reference. switch Statements

Structured Programming. Flowchart Symbols. Structured Programming. Selection. Sequence. Control Structures ELEC 330 1

1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?

CS 117 Programming II, Spring 2018 Dr. Ghriga. Midterm Exam Estimated Time: 2 hours. March 21, DUE DATE: March 28, 2018 at 12:00 PM

Sample Code: OUTPUT Daily Highs & Lows

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

University of Dublin

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Problem Solving: Storyboards for User Interaction

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement

Exam 2. CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson. Question Points Score Total: 80

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

CMPS 221 Sample Final

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

do { statements } while (condition);

To become familiar with array manipulation, searching, and sorting.

1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A.

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

conditional statements

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

Due Date: See Blackboard

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

Multiple Choice Questions (20 questions * 5 points per question = 100 points)

1) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed?

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

THE INTEGER DATA TYPES. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

Introduction to C++ (Extensions to C)

Notes on the 2008 Exam

C++ Final Exam 2017/2018

In this chapter you will learn:

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

COSC 320 Exam 2 Key Spring Part 1: Hash Functions

Computer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:

Chapter Four: Loops II

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.7. User Defined Functions II

Local and Global Variables

Chapter 4 - Notes Control Structures I (Selection)

Why Is Repetition Needed?

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

Getting started with C++ (Part 2)

Classes and Data Abstraction. Topic 5

Midterm Practice Exam

CSCE 2004 Midterm Exam Spring 2017

Unit 7. 'while' Loops

PIC 10A. Review for Midterm I

Note: The buy help from the TA for points will apply on this exam as well, so please read that carefully.

Exam 1 Practice CSE 232 Summer 2018 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

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

Chapter Four: Loops. Slides by Evan Gallagher. C++ for Everyone by Cay Horstmann Copyright 2012 by John Wiley & Sons. All rights reserved

LAB: WHILE LOOPS IN C++

Midterm Exam. Sample Solutions

REPETITION CONTROL STRUCTURE LOGO

Review. Relational Operators. The if Statement. CS 151 Review #4

Fundamentals of Programming CS-110. Lecture 2

Deitel Series Page How To Program Series

As an example using arrays, let s write some code to get started with the Upthrust game. We can use a 2D array to represent the game board.

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15)

WARM UP LESSONS BARE BASICS

Week 3: Pointers (Part 2)

1st Midterm Exam: Solution COEN 243: Programming Methodology I

CPT101- Principles of Programming

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7. CS 5301 Spring 2018

Learning Objectives: General Description: DONE DONE Structure Chart

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

Lab Instructor : Jean Lai

Objectivities. Experiment 1. Lab6 Array I. Description of the Problem. Problem-Solving Tips

Ch 6. Functions. Example: function calls function

READ THIS NOW! Do not start the test until instructed to do so!

BEng (Hons) Electronic Engineering. Resit Examinations for / Semester 1

Final Exam, Version 3 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS240 BRANCHING STATEMENTS

CS 101 Computer Programming and utilization. Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal Rekhi Building IIT Bombay

BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18)

UNIVERSITY OF SWAZILAND SUPPLEMENTARY EXAMINATION, JULY 2013

causing a set of statements (the body) to be executed repeatedly. C++ provides three control structures to support iteration (or looping).

Linked List using a Sentinel

Introduction to Programming

CS 240 Data Structure Spring 2018 Exam I 03/01/2018

Notes on the 2016 Exam

Transcription:

The American University in Cairo Computer Science & Engineering Department CSCE 106-08 Dr. KHALIL Exam II Spring 2010 Last Name :... ID:... First Name:... Form - I EXAMINATION INSTRUCTIONS * Do not turn this page until asked to do so. * Exam time is 75 minutes. * Put the answers on the same question sheet, do not use any additional papers, even for scratch. * Write your name, ID, section no. in the indicated places. * Read the exam instructions. * Read the honesty policy. * Sign the following statement. Academic Integrity Policy Cheating in Exams is a violation of the Academic Integrity policy of AUC. Whispering, talking, looking at someone else s paper, or copying from any source is considered cheating. Any one who does any of these actions or her/his answers indicates that she/he did any of them, will receive a punishment ranging from zero in this exam to failing the course. If repeated, it may lead to dismissal from AUC. I have read the honesty policy and exam instructions and I am presenting this exam as entirely my effort. Signature: --------------------------------------------------------------------------------------------------------------------------- DO NOT USE THIS SECTION Question Points Grade 1 20 2 15 3 15 4 10 5 20 6 20 + 10 Total 100 1

Question 1 (20 points) Show the output of each of the following program segments: const int ten = 10; int d; int n = 27049; do { d = n % ten; cout << d; n /= ten; } while (n!= 0); int x = 1, y = 2; while (x < 3) y /= x++; cout << x = << setw(3) << x << << y = <<setw(3)<<y<<endl; # include <iostream> # include <iomanip> using namespace std; void main() { int a = 5, b = 7, c = 3, t; do { if ( b > a) { t = a; a = b; b = t; } if ( c > b ) { t = b; b = c; c = t; } } while (( b > a ) ( c > b )); } cout << "a = " << setw(3) << a << endl; cout << "b = " << setw(3) << b << endl; cout << "c = " << setw(3) << c << endl; int x = 1, y = 1; while (x < 4) { y *= x++; cout << x = <<setw(3)<<<x<< y = <<setw(3)<<y<<endl; } int x, y; for (x = 5; x > 10; x *= 2) for (y = 3; y <= 5; y++) cout << setw(3) << x << setw(3) << y << endl; cout << The Final Value Is: << setw(5) << x / 2 % y; 2

Question 2 (15 points) A Prime number is a positive integer number greater than 1 which is only divisible by itself (and eventually by 1). The first prime number is 2, and the next is 3, and so on. The following C++ program takes a positive integer number greater than 1 and less than 100 and prompts the user whether the entered number is prime or nonprime. There are some missings (represented by dots) in the given program. Complete these missings such that the program could be compiled and run correctly. The program does not accept any integer number outside the given range (greater than 1 and less than 100). The Program # include <iostream> #include <iomanip> using namespace std; void main () { int num, c; bool flag; do { cout << Enter a positive integer greater than 1 and less than 100: << endl; cin >> num; } while (..);..;..; while ( ) if (...) else.....;.; if ( ) cout << The number << setw(4) << num << is Non Prime << endl; else cout << The number << setw(4) << num << is prime << endl; } 3

Question 3 (15 points) Write a program that uses nested loops to produce the following output: 1 2 3 4 5 6 7 8 0 2 3 4 5 6 7 8 0 0 3 4 5 6 7 8 0 0 0 4 5 6 7 8 0 0 0 0 5 6 7 8 0 0 0 0 0 6 7 8 0 0 0 0 0 0 7 8 0 0 0 0 0 0 0 8 Question 4 (10 points) Write a C++ program to print all the positive integers that are divisible by 6 but not divisible by 9 in the range 1 to 2000 (inclusive). 4

Question 5 (20 points) In a laboratory experiment, readings of certain measurement are entered instantaneously to a computer one after the other for processing. Write a C++ program that accepts these readings and computes their average value at the end of the experiment. The program readss one reading value every execution of an input operation (cin) but accepts only positive values to compute the average value and discards all negative values. At the end of the experiment, the sentinel value 1111 is entered as an input to the program to stop processing and display the results. The sentinel value should not be considered as one of the valid or invalid readings. The displayed results should include the average value of all valid readings, the number of all valid readings, and the number of invalid readings. Use proper formats to display the results. The Program 5

Question 6 (20 points + 10 bonus ) A graduating student of AUC is awarded an honorary degree according to his/her final GPA. The honorary degree is granted according to the following rules: Final GPA Honorary Degree 3.80 <= GPA <= 4.00 Highest Honors 3.60 <= GPA < 3.80 High Honors 3.40 <= GPA < 3.60 Honors 2.00 <= GPA < 3.40 Pass with no Honors Draw a flow chart and write a program in C++ to input the GPA of a student and print out his/her honorary degree. Show the three phases of software development: the analysis, design, and implementation. Implement your solution in C++ using nested-if structure. As a bonus (10 points), give the equivalent implementation using the switch structure. Enforce validation on the input GPA such that it is not less than 2.00 and not greater than 4.00 The Analysis The Flow Chart 6

7 The Program Using nested-if structure

The Program Using switch structure (Bonus) Good Luck 8