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

Similar documents
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

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. Instructor: Final Exam Fall Section No.

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 Instructor: Final Exam Fall 2014

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

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

Solve only 2 out of 3 questions

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.

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

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

CSCE Practice Midterm. Data Types

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

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

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

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

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

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

Sample Code: OUTPUT Daily Highs & Lows

Name Section: M/W or T/TH. True or False (14 Points)

WARM UP LESSONS BARE BASICS

CPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)

Ch 6. Functions. Example: function calls function

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

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

REVIEW. The C++ Programming Language. CS 151 Review #2

Programming. C++ Basics

Chapter 1 INTRODUCTION

CSCE 206: Structured Programming in C++

CSCE Practice Midterm. Data Types

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

True or False (12 Points)

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

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

Basic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces

do { statements } while (condition);

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

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)

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

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

Fundamentals of Programming CS-110. Lecture 2

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

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

Name SECTION: 12:45 2:20. True or False (12 Points)

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

Problem Solving: Storyboards for User Interaction

Computer Programming : C++

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

CMPS 221 Sample Final

Introduction to Programming

Review. Modules. CS 151 Review #6. Sample Program 6.1a:

Summary of basic C++-commands

True or False (15 Points)

Definition Matching (10 Points)

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Introduction to C++ (Extensions to C)

BITG 1233: Introduction to C++

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

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

C++ Final Exam 2017/2018

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

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Starting Out with C++: Early Objects, 9 th ed. (Gaddis, Walters & Muganda) Chapter 2 Introduction to C++ Chapter 2 Test 1 Key

EECS402 Lecture 02. Functions. Function Prototype

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

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

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

A First Program - Greeting.cpp

CSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

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!

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

CPE Summer 2015 Exam I (150 pts) June 18, 2015

Due Date: See Blackboard

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

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

Chapter Four: Loops II

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

CSC 126 FINAL EXAMINATION FINAL Spring 2012 B. Name (last, First) Instructor. Total Possible. Received

C++ Programming for Non-C Programmers. Supplement

CSCE 2004 Final Exam Spring Version A

Introduction to Programming EC-105. Lecture 2

CMSC 202 Midterm Exam 1 Fall 2015

Introduction to Programming using C++

Introduction to Computer Science Midterm 3 Fall, Points

CSCE 2004 Midterm Exam Spring 2017

1) You want to determine whether time has run out. The following code correctly implements this:

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

Getting started with C++ (Part 2)

BITG 1113: Array (Part 1) LECTURE 8

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

Chapter 4 - Notes Control Structures I (Selection)

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

Midterm Practice Exam

Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A

PIC 10A. Review for Midterm I

Transcription:

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science Instructor: Final Exam Fall 2011 Last Name :... ID:... First Name:... Section No.: EXAMINATION INSTRUCTIONS * Do not turn this page until asked to do so. * Exam time is 120 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 honesty 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 15 2 25 3 10 4 15 5 15 6 20 Total 100 1

Question 1 (15 points) Tick only one possible answer for each of the following: 1)!((x == x) && (y > 10)) is equivalent to: a. True [ ] b. (x!= x) && (y < 10) [ ] c. (x!= x) (y <= 10) [ ] d. None of the above [ ] 2) Intellectual Property: a. A form of protection that can be granted by the government for an invention; gives exclusive rights of an invention to its inventor for 20 years. [ ] b. Standards of moral conduct as they relate to computer use. [ ] c. The rights to which creators of original creative works (such as software, artistic, literary works, inventions, and more) are entitled. [ ] d. The legal right to sell, publish, or distribute an original software, artistic or literary work; is held by the creator of a work as soon as it exists in physical form. [ ] 3) The value of ((x 4)!= 4) && ((x 4) == 4) is: a. (x 4) [ ] b. True [ ] c. (x + 4) [ ] d. none of the above [ ] 4) The Compiler is a software that: a. translates a high-level language program into machine language [ ] b. translates an assembly language program into machine language [ ] c. lets users display and view a web document [ ] d. None of the above [ ] 5) The value of ((x <= y ) True) is: a. ( x > y) [ ] b. ( x <= y) [ ] c. False [ ] d. none of the above [ ] 6) The ALU is the unit of computer responsible of: a. Storing programs and data permanently [ ] b. Performing arithmetic and logical operations [ ] c. Performing Input/Output operations [ ] d. None of the above [ ] 7) In binary: 1111 + 1111 =? a. 10000 [ ] b. 11110 [ ] c. 11011 [ ] d. 11111 [ ] 8) In C++, the statement: if (1!= 1) cout << 1; else cout << 0; will produce: b. 1 [ ] c. ( 1!= 1) [ ] d. 0 [ ] d. none of the above [ ] 9) (10000000) 2 is equivalent to: a. (256) 10 [ ] b. (127) 10 [ ] c. (128) 10 [ ] d. None of the above [ ] 10) An equivalent expression of ((x <= y ) False) is: c. ( x > y) [ ] d. ( x <= y) [ ] e. False [ ] d. none of the above [ ] 2

Question 2 (25 points) Show the output of each of the following program segments: void drawl(); int func(int n); void main () drawl(); cout << setw(3) << k << setw(8) << func(k) << endl; drawl(); for (int k=0; k <= 6; k += 2) cout << setw(3) << k << setw(8) << func(k) << endl; drawl(); int func(int n) int f = 1; for (int m=2; m <= n; m++) f = m * f; return f; void drawl() for (int c = 1; c <= 11; c++) cout << - ; cout << endl; float a = 2, b = 2, c = 1.5, x; int d = 4, e = 5.5, y; x = a * b - c + d / e; y = a * (b - c) + e / d; cout << "x = " << setw(4) << x << " y = " << setw(4) << y << endl; int x = 1, y = 1, z; y *= x++; cout << x = << setw(2) << x << y = << setw(2) << y << endl; x = 6; y = 2; z = --x / y++; y = z-- + x++; cout << x = << x << y = << y << z = << z << endl; 3

int B[4]; const int two = 2; int n = 11; int c = 3; int nn = n; do B[c] = nn % two; nn /= two; c--; while (nn!= 0); cout << The equivalent value of << n << is ; for (int c = 0; c < 4; c++) cout << B[c]; cout << endl; int mynum (int); void main() for ( int n = 1; n < 6; n++) for (int m = 1; m <= n; m++) cout << mynum(n); cout << endl; int mynum (int nn) const int one = 1; const int two = 2; const int three = 3; switch(nn % three) case 1: return one; break; case 2: return two; break; default: return three; 4

Question 3 (10 points) Draw the Flowchart of the following program and show its final output: # include <iostream> # include <iomanip> using namespace std; void main() int a = 5, b = 7, c = 3, t; FlowChart 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 5

Question 4 (15 points) Write a C++ program that uses only two nested loops and switch structure to produce the following output: @ @ @ @ @ @ & & & & & & & & & & & & & & & @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ & & & & & & & & & & 6

Question 5 (15 points) A Perfect integer is a positive integer number greater than 1 and the sum of its factors (including 1) is equal to the number itself. For example, 6 is the first perfect number because 1 + 2 + 3 (the factors of 6) = 6) and 28 is the next perfect number because the sum of its factors 1 + 2 + 4 + 7 + 14 = 28 which is equal to the number itself. The following C++ modular program takes a positive integer number greater than 1 and less than 1000 and prompts the user whether the entered number is perfect or not. 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 1000). The Program # include <iostream> # include <iomanip> using namespace std; bool perfect(int); void main () int num; do cout << Enter an integer number between 1 and 1000: << endl; cin >> num; while (. ); If (.) cout << The number << setw(5) << num << is Perfect << endl; else cout << The number << setw(5) << num << is NOT Perfect << endl; bool (.. n) int sum =..; for ( int c = 1;... ) If ( n % c == 0) ; return (....); 7

Question 6 (20 points) Write a modular C++ program using functions to generate a table showing the area of a circle for a sequence of radius values (integer values). The program should read the start integer radius (startrad), the end integer radius (endrad) and the step value (stepval). The program should validate the user input through enforcing the following conditions: The start integer radius should be greater than 0 and less than 100. The difference between the end integer radius and the start integer radius should not be less than 10. The step value should be greater than 0 and not greater than the difference between the end integer radius and the start integer radius. The computed area value should be printed rounded to the nearest hundredth. (Hint: define a function to print the header of the table, a second function to get the area value for a given radius value, a third function to print the footer of the table) An Example: Start Integer radius (startrad) = 1, End Integer radius (endrad) = 10, Step Value (stepval) = 1 ------------------------------------------------ Radius Area of Circle ------------------------------------------------ 1 3.14 2 12.57 3 28.29. 10 314.29 ------------------------------------------------- 8

9 Good Luck