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

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

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I 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 Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

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

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

Chapter 1 INTRODUCTION

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

Introduction to Computer Science Midterm 3 Fall, Points

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

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

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

WARM UP LESSONS BARE BASICS

(6) The specification of a name with its type in a program. (7) Some memory that holds a value of a given type.

A First Program - Greeting.cpp

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

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.

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

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

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

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in 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):

CSCE Practice Midterm. Data Types

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

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

1a Computers, Problem Solving!

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

Fundamentals of Programming CS-110. Lecture 2

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

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

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

Unit 7. 'while' Loops

Getting started with C++ (Part 2)

Midterm Practice Exam

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

CSCE Practice Midterm. Data Types

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

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

True or False (12 Points)

Copy: IF THE PROGRAM or OUTPUT is Copied, then both will have grade zero.

Introduction to Programming EC-105. Lecture 2

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

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

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

Midterm Exam. Sample Solutions

Local and Global Variables

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

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

MEHRAN UNIVERSITY OF ENGINEERING AND TECHNOLOGY, JAMSHORO. FIRST TERM FIRST YEAR (1 ST TERM) B.E.(ELECTRICAL) REGULAR EXAMINATION 2009 OF 09-BATCH.

Boolean Data-Type. Boolean Data Type (false, true) i.e. 3/6/2018. The type bool is also described as being an integer: bool bflag; bflag = true;

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

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

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?

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

Chapter 4 - Notes Control Structures I (Selection)

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

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

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!

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

CSCE 110 PROGRAMMING FUNDAMENTALS

VARIABLES & ASSIGNMENTS

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

Other operators. Some times a simple comparison is not enough to determine if our criteria has been met.

conditional statements

BITG 1233: Introduction to C++

Introduction to Programming

A Freshman C++ Programming Course

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

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

True or False (15 Points)

You must pass the final exam to pass the course.

Chapter void Test( int, int, int ); // Function prototype int main() // Function heading { int h; // Local variable

Introduction to Programming I COS1511 School of Computing Revision Notes

Lab Instructor : Jean Lai

Score score < score < score < 65 Score < 50

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

PIC 10A. Final Review: Part I

Introduction to the C++ Programming Language

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

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

REPETITION CONTROL STRUCTURE LOGO

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

CISC2000/ of 6

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

CSCI-1200 Data Structures Fall 2011 Lecture 1 Introduction and Background

Study Guide for Test 2

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

Summary of basic C++-commands

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

CHAPTER 3 BASIC INSTRUCTION OF C++

Looping and Counting. Lecture 3 Hartmut Kaiser hkaiser/fall_2012/csc1254.html

Transcription:

The American University in Cairo Computer Science & Engineering Department CSCE 1001 Instructor: Final Exam Fall 2014 Last Name :... ID:... First Name:... Form I- 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 10 2 20 3 20 4 15 5 15 6 20 Total 100 1

Question 1 (10 points) Tick only one possible answer for each of the following: 1) In binary: 1111 + 11001 =? a. 101000 [ ] b. 100110 [ ] c. 110110 [ ] d. none of the above [ ] 2) The Boolean expression!((x > 4 ) && (x<10)) can be simpilified into: a. (x <= 4) && (x>=10) [ ] b. (x < 4) && (x>10) [ ] c. (x <= 4) (x>=10) [ ] d. (x > 4) (x<10) [ ] 3) The software that controls and manages the computer resources is: a. Linker [ ] b. Loader [ ] c. Web browser [ ] d. Operating system [ ] 4) The value of ((x 4)!= 4) && ((x 4) == 4) is: a. (x 4) [ ] b. False [ ] c. (x + 4) [ ] d. none of the above [ ] 5) A Kilobyte is: a. 2 10 bytes [ ] b. 2 20 bytes [ ] c. 2 30 bytes [ ] a. 2 40 bytes 6) Illegally copying software for use on another computer: a. Computer fraud [ ] b. Worm [ ] c. Virus [ ] d. Software piracy [ ] 7) 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 [ ] 8) The value of ((x <= y ) True) is: a. ( x > y) [ ] b. ( x <= y) [ ] c. False [ ] d. none of the above [ ] 9) A computer that provides resources to other computers in a network: a. Modem [ ] b. Web browser [ ] c. Server [ ] d. none of the above [ ] 10) (110) 10 + (110) 2 is equivalent to: a. (220) 10 [ ] b. (1110100) 2 [ ] c. (1100) 2 [ ] d. None of the above [ ] 2

Question 2(20 points) Show the output of each of the following program segments: int A[5] = 3, 5, 2, 8, 1; int T; bool flag; do flag = false; for (int j = 0; j < 4; j++) If (A[j] > A[j+1]) T = A[j]; A[j] = A[j+1]; A[j+1] = T; flag = true; while (flag); for(int i=0; i<5; i++) cout<<a[i]<<endl; void swap (int&, int&); void main() int a = 53, b = 57, c = 39; do if ( b > a) swap (a, b); if ( c > b ) swap (b, c); while (( b > a ) ( c > b )); cout << "The two required values are: << endl; cout << setw(6) << a << setw(6) << b << endl; void swap (int& X, int& Y) int T = X; X = Y; Y = T; int B[10], n = 45, c = 0; cout << The equivalent value of << n << is ; do 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

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; 4

Question 3 (20 points) A person s maximum heart rate can be computed as hmax= 191.5 (0.007 age 2 ) where age is the person s age. The heart rate index (HRI) is an integer defined as the ratio of the heart rate (HR) multiplied by 10 to the maximum heart rate (hmax) is as indication of the person s exercise level. A person s exercise level is evaluated as follows HRI = 10*HR/hMax Exercise Level HRI<0.5 too low 0.5<=HRI<0.6 Warming up 0.6<= HRI< 0.7 Fat burning 0.7<= HRI < 0.8 Endurance training 0.8 <= HRI High intensity Draw a flow chart and write a program in C++ to input the age and HR of a person and output his maximum heart rate and the exercise level. Show your analysis, draw a flowchart, and write down the corresponding program. Enforce validation on the input age which is a positive integer less than 100 and HR which is a positive integer less than 500. Write the program using if-else statements 5

Do one of the following: (1) write the program analysis and draw the flow chart OR (2) Rewrite the program using switch-case statements 6

Question 4 (15 points) Write only the C++ nested-loop to produce the following pattern: # & & @ @ @ # # # # & & & & & @ @ @ @ @ @ # # # # # # # & & & & & & & & The Loop 7

Question 5 (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 lists all the prime numbers in the range of 2 to 500. 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;... prime ( ); void main () for (int num = 2;..;.. ) if (.) cout << num << endl; bool prime ( int n) bool flag = true; int c = 2; do if ( ) else..; flag = false; while (.);..; 8

Question 6 (20 points) Write a program that includes two functions called min and avg. min takes as input three integers and returns the minimum, whereas avg takes as input three integers and returns their average (a float). The program should do the following: (1) Ask the user how many times to repeat the program (N) (2) Repeat step (3) to (5) N times (3) Ask the user for three numbers (4) Uses the function min to compute the minimum value and the function avg to compute their average (5) Print the minimum and average on the screen........ 9

Good Luck 10