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

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

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

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

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

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

Solve only 2 out of 3 questions

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

CSCE Practice Midterm. Data Types

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

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.

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

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

CSCE Practice Midterm. Data Types

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

Learning Objectives: General Description: DONE DONE Structure Chart

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

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.

LAB 7.1 Working with One-Dimensional Arrays

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

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

BITG 1233: Introduction to C++

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

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

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

Write a program that displays all the even integers between 1 and 100, inclusive

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

LAB 4.1 Relational Operators and the if Statement

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

Sample Code: OUTPUT Daily Highs & Lows

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

Lab 15 Review of Arrays, Array of Objects and Vector Dr. John Abraham, Professor

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

CMPS 221 Sample Final

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

Chapter 4 - Notes Control Structures I (Selection)

I/O Streams and Standard I/O Devices (cont d.)

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

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

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

Midterm Practice Exam

Getting started with C++ (Part 2)

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

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

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

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

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

WARM UP LESSONS BARE BASICS

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

Introduction to C++ (Extensions to C)

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

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

BITG 1113: Array (Part 1) LECTURE 8

Midterm Exam. Sample Solutions

Do not turn to the next page until the start of the exam.

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

CSCE 206: Structured Programming in C++

Ch 6. Functions. Example: function calls function

Definition Matching (10 Points)

System Design and Programming II

CPT101- Principles of Programming

Functions, Arrays & Structs

Chapter 3 Problem Solving and the Computer

Functions, Arrays & Structs

a. a * c - 10 = b. a % b + (a * d) + 7 =

Sonoma State University Computer Science Department CS 115 Fall 2010 Watts. Project 3 Part 1

C++ As A "Better C" Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan.

READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Do not start the test until instructed to do so!

Final Examination Semester 2 / Year 2005

University of Dublin

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

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, October 13, 2015

CSCE 2004 Midterm Exam Spring 2017

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

BENG (HONS) ELECTRONIC ENGINEERING BENG (HONS) TELECOMMUNICATIONS. Cohort: BEE/10A/FT, BEE/10B/FT &BTEL/10B/FT

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

UNIVERSITY OF SWAZILAND SUPPLEMENTARY EXAMINATION, JULY 2013

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

Multiple Choice Questions (20 questions * 6 points per question = 120 points)

Problem Solving: Storyboards for User Interaction

Programming. C++ Basics

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop

CS 141, Introduction to Computer Science Fall Midterm Exam

CSE030 Fall 2012 Final Exam Friday, December 14, PM

Classes and Data Abstraction. Topic 5

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.

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

Notes on the 2008 Exam

The following is a typical execution run of this program:

CS242 COMPUTER PROGRAMMING

Deitel Series Page How To Program Series

do { statements } while (condition);

In this chapter you will learn:

Week 3: Pointers (Part 2)

Transcription:

The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: 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 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 30 2 15 3 20 4 35 Total 100 1

Question 1 (30 points) Show the output of the following program: Program # include <iostream> # include <iomanip> using namespace std; Output void main() int num = 1101, d, s = 0; const int ten = 10; d = num % ten; s = s + d; num = num / ten; d = num % ten; s = s + 2 * d; num = num / ten; d = num % ten; s = s + 4 * d; d = num / ten; s = s + 8 * d; cout << The final result = << setw(4) << s << endl; float a = 2, b = 2, c = 1.5, x = 45.5678, z; int d = 4, e = 2.5, y; z = a * b - c + (e + 1) / d + 2.235; y = a * (b - c) + d / (e + 1); cout << "x = " << setprecision(2) << x << endl; cout << " y = " << y << endl; cout << " z = " << setprecision(0) << z << endl; int a = 5, b = 3, c = 7; if ((a > b) && (false)) cout << the required number = << a << endl; if ((b > c) (true)) cout << The required number = << b << endl; cout << The required number = << c << endl; int a =.., b =.., c =..; // a, b, and c are assigned some values if ((a > b) && (a <= b)) cout << It is the first case!! << endl; if ((b == c) (b!= c)) cout << It is the second case!! << endl; cout << It is the third case!! << endl; 2

Question 2 (15 points) Draw the Flowchart of the following program and show its final output: # include <iostream> FlowChart # include <iomanip> using namespace std; void main() int a = 5, b = 7, c = 3, t; if ( b > a) t = a; a = b; b = t; if ( c > b ) t = b; b = c; c = t; if ( b > a) t = a; a = b; b = t; cout << "a = " << setw(3) << a << endl; cout << "b = " << setw(3) << b << endl; cout << "c = " << setw(3) << c << endl; Program Output Question 3 (20 points) 3

The following C++ program takes the area of base and height of a pyramid and computes and prints out its volume rounded to the nearest hundtredth. The program validates the user input to accept only values that are greater than 0 for both area and height and display an error message otherwise. The formula for computing the pyramid s volume is: Volume of Pyramid = 1/3 X area X height 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 #include <iostream>.. using namespace std; void main() float height, area, volume; cout << "Enter a value for the area : "; cin >> area; cout << "Enter a value for the height : "; cin >> height;... volume =.. cout << The Volume of Pyramid = << setw(8) <<... << endl; cout << Error, Invalid Input Values!! << endl; 4

Question 4 (35 points) A student takes three exams in a course and receives a score for each. Each score is an integer number between 0 and 100 (inclusive). The course instructor considers the sum of the best two scores to determine the letter grade of the student in the course according to the following rules: Sum of the best two scores (Out of 200) Sum >= 180 Letter Grade A 160 <= Sum < 180 B 140 <= Sum < 160 C 120 <= Sum < 140 D Sum < 120 F Write a C++ program that takes the three scores of a student, computes the sum of the best two, and determines and displays the deserved letter grade. The program should display an error message and terminate if the computed sum of the best two scores is less than 0 or greater than 200. Be sure to use proper formatting and appropriate comments in your code. The output should be clearly labeled. Show the three phases of software development: the analysis, design (draw a Flow Chart), and implementation. You have to write the program once using nested-if structure and second using the switch structure. The Analysis 5

6 The Flow Chart

The Program Using the nested-if structure 7

The Program Using the switch structure Good Luck 8