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

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. 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 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 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.

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

CS 1044 Programming in C++ Test 1 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties.

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

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

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!

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

LAB 4.1 Relational Operators and the if Statement

CSCE 2004 Midterm Exam Spring 2017

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

Sample Code: OUTPUT Daily Highs & Lows

Chapter 4 - Notes Control Structures I (Selection)

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


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

C++ Programming: From Problem Analysis to Program Design, Third Edition

CSCE Practice Midterm. Data Types

Chapter 1 INTRODUCTION

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 206: Structured Programming in C++

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

Introduction to Computer Science Midterm 3 Fall, Points

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

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

C++ Final Exam 2017/2018

Summary of basic C++-commands

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

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

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

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

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

C++ Programming for Non-C Programmers. Supplement

conditional statements

Computer Programming : C++

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

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

FORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each):

5. Assuming gooddata is a Boolean variable, the following two tests are logically equivalent. if (gooddata == false) if (!

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

CSCE Practice Midterm. Data Types

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

C++ Programming for Non-C Programmers. Supplement

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

EECS402 Lecture 02. Functions. Function Prototype

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

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

Fundamentals of Programming CS-110. Lecture 2

Computer Programming

Introduction to Programming I COS1511 School of Computing Revision Notes

Ch 6. Functions. Example: function calls function

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

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++

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

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

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

CPT101- Principles of Programming

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

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

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

The University Of Michigan. EECS402 Lecture 02. Andrew M. Morgan. Savitch Ch. 3-4 Functions Value and Reference Parameters.

True or False (15 Points)

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

WARM UP LESSONS BARE BASICS

Boolean Algebra Boolean Algebra

C++ basics Getting started with, and Data Types.

CS101 PLEDGED SPRING 2001

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

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

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

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

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

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

Midterm Practice Exam

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

Programming. C++ Basics

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

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

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

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS COSC 1320: INTRODUCTION TO C++ PROGRAMMING COMPUTER TECHNOLOGY & OFFICE ADMINISTRATION DEPARTMENT

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

Notes on the 2008 Exam

C++ Input/Output: Streams

Fundamentals of Structured Programming

Definition Matching (10 Points)

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

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

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

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

Transcription:

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science Instructor: Dr. Khalil Final Exam Fall 2012 Last Name :... ID:... First Name:... Form I Section No.: (04) EXAMINATION INSTRUCTIONS * Do not turn this page until asked to so. * Exam time is 120 minutes. * Put the answers on the same question sheet, 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 es 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 10 2 30 3 10 4 20 5 30 Total 100 1

Question 1 (10 points) Tick only one possible answer for each of the following: 1) The Boolean expression!(x > y ) can be simpilified into: a. ( x < y) [ ] b. ( x >= y) [ ] c. True [ ] 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. False [ ] 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 cument [ ] d. None of the above [ ] 5) Suppose that x is an int variable that contains the value 2 and y is an int variable that contains the value 5, the new value of x after the execution of x+=2*y; will be a. 1 [ ] b. 12 [ ] c. 10 [ ] 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) The value of ((x <= y ) True) is: b. ( x > y) [ ] c. ( x <= y) [ ] d. False [ ] d. none of the above [ ] 8) In C++, the statement: if (1 == 1) cout << 1; else cout << 0; will produce: c. 0 [ ] d. ( 1!= 1) [ ] e. 1 [ ] d. none of the above [ ] 9) (110) 10 + (110) 2 is equivalent to: a. (220) 10 [ ] b. (1110100) 2 [ ] c. (1100) 2 [ ] d. None of the above [ ] 10) A computer crime in which a person s social security number is taken is called: d. Hacking [ ] e. Identity theft [ ] f. E-harassement [ ] d. Social re-engineering [ ] 2

Question 2 (30 points) Show the output of each of the following program segments: void drawline(char); int func(int); void main () drawline( # ); cout << setw(3) << k << setw(8) << func(k) << endl; drawline( - ); for (int k=0; k <= 5; k += 2) cout << setw(3) << k << setw(8) << func(k) << endl; drawline( # ); int func(int n) int f = 1; for (int m=2; m <= n; m++) f = m * f; return f; void drawline(char ss) for (int c = 1; c <= 10; c++) cout << ss; cout << endl; float a = 3, b = 2, c = 1.5, x; int d = 4, e = 6.5, y; x = a * b - c + ++d / e++; y = a * (b c) + e / --d; cout << " x = " << setw(4) << x << endl; cout << " y = " << setw(4) << y << endl; a = 3.3456; b = 5.9876; cout << setprecision(2); cout << setw(4) << a << setprecision(1) << setw(4) << b << endl; cout << setprecision(0) << setw(4) << a << setw(4) << b << endl; int B[4], n = 36, c = 0; cout << The equivalent value of << n << is ; B[c] = n % 2; n = n / 2; c++; while (n!= 0); for (int k = c-1; k >= 0; k--) cout << B[k]; cout << endl; 3

for ( int c = 2; c < 4; c++) for ( int k = c; k <= 3 * c; k += c) switch ( k % 3 ) case 0: cout << setw(3) << "Zero"; break; case 1: cout << setw(3) << "One"; break; default: cout << setw(3) << "Two"; cout << endl; void swap (int&, int&); void main() int a = 6.5, b = 5.3, c = 3.2; if ( b < a) swap (a, b); if ( c < b ) swap (b, c); while (( b < a ) ( c < b )); cout << "The Final value is: << endl; cout << setw(4) << (b + c) / 2 << endl; void swap (int& X, int& Y) int T = X; X = Y; Y = T; int a =.., b =.., c =..; // a, b, and c are assigned some values if ( (a > b) && false ) cout << It is the first case!! << endl; else if ((b == c) && (b!= c)) cout << It is the second case!! << endl; else cout << It is the third case!! << endl; string student; student = "Khaled"; cout << student.length() << endl; cout << student.find( e ) << endl; 4

Question 3 (10 points) Draw a Flow Chart for the following C++ main function: void main() int c_yes = 0; int c_no = 0; char vote; cout << "To exit press Q" << endl; cout << "Do you accept the constitutional draft?" << endl; cin >> vote; while (( vote!= 'q' ) && ( vote!= 'Q' )) if ( vote == 'Y' ) (vote == 'y' )) c_yes++; else if ( vote == 'N' (vote == 'n' ) ) c_no++; cin >> vote; cout << "The number of Yes votes = " << c_yes << endl; cout << "The number No votes = << c_no << endl; Flow Chart 5

Question 4 (20 points) Write a program that reads a positive integer (between 0 and 99999) from the user. The program then takes a single digit (from 0 to 9) from the user. The program will then call the function exists that takes the positive integer and the digit and returns the number of occurrences of the digit in the previously entered positive number. All data entry validations are required. (Example: if the user enters 27817, then enters 7, the program will display: The number of occurrences of 7 in 27817 is 2 ) The Program # include <iostream> using namespace std; int exists(int, int); void main () int num, n; cout << Enter an integer number between 0 and 99999: << endl; cin >> num; while (. ); cout << Enter an integer digit between 0 and 9: << endl; cin >> n; while (. ); cout << The number of occurrences of << n << in << num << is <<... << endl; (.. m, d) int count =..; If ( m % 10 == ) ; M = m / 10; while ( ); return (....); 6

Question 5 (30 points) One interesting application of computers is the drawing of graphs and bar charts (sometimes called histograms ). Write a modular program that performs the following: a. Take a user input representing a number of positive integer values (n) that the program will process. This number (n) should be greater than 0 and not more than 20. b. Draw a header for the results, as shown in the example below. c. Take each positive integer value one by one to print a line containing the read value (on two positions), followed by a space and then a number of adjacent # s equal to the integer read value. Each entered integer value should be greater than 0 and not more than 15. d. Print a footer showing some statistical results: the average of the (n) entered values (rounded to the nearest integer), the highest value, the lowest value, and the number of values below 5. The following is just an example of the program output for n = 10 and the values entered one by one for processing are 5, 10, 2, 7, 7, 15, 9, 3, 12, and 2. ============================= Number of Values: 10 Results: ------------------------------------------------- 5 ##### 10 ########## 2 ## 7 ####### 7 ####### 15 ############### 9 ######### 3 ### 12 ############ 2 ## ------------------------------------------------- Average = 7 Highest Value = 15 Lowest Value = 2 Number of Values Below 5 = 3 ============================= Hints: 1. Define functions to draw header and footer. 2. Define a function that takes as an input an integer value and prints out its line. (the integer value itself on two positions, followed by a space and then its corresponding number of # s.... 7

8

9 Good Luck