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

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

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

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

CSCE Practice Midterm. Data Types

Sample Code: OUTPUT Daily Highs & Lows

CSCE Practice Midterm. Data Types

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

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

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

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration 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.

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

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

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

WARM UP LESSONS BARE BASICS

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

LAB 4.1 Relational Operators and the if Statement

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

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

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

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

CMPS 221 Sample Final

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

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.

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

Functions, Arrays & Structs

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

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

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

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

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

C++ Final Exam 2017/2018

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

BITG 1233: Introduction to C++

Due Date: See Blackboard

Programming. C++ Basics

Getting started with C++ (Part 2)

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

Functions in C++ Problem-Solving Procedure With Modular Design C ++ Function Definition: a single

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

Introduction to Computer Science Midterm 3 Fall, Points

EECS402 Lecture 02. Functions. Function Prototype

CHAPTER 4 FUNCTIONS. Dr. Shady Yehia Elmashad

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

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

CS101 PLEDGED SPRING 2001

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

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

CSc 10200! Introduction to Computing. Lecture 4-5 Edgardo Molina Fall 2013 City College of New York

Chapter Four: Loops II

In this chapter you will learn:

Chapter 17 - Notes Recursion

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

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

C++ Quick Reference. switch Statements

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

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

Arrays. Week 4. Assylbek Jumagaliyev

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

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

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

CSC102 INTRO TO PROGRAMMING WITH PYTHON LECTURE 27 CRASH COURSE IN C++ MICHAEL GROSSBERG

Computer Science II Lecture 1 Introduction and Background

LAB 7.1 Working with One-Dimensional Arrays

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

Lecture 4 Tao Wang 1

CSCE 2004 Midterm Exam Spring 2017

CPT101- Principles of Programming

Ch 6. Functions. Example: function calls function

Chapter 3 - Functions

6.1. Chapter 6: What Is A Function? Why Functions? Introduction to Functions

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

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

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

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

Problem Solving: Storyboards for User Interaction

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

A Freshman C++ Programming Course

3.1. Chapter 3: The cin Object. Expressions and Interactivity

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

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.

Fundamentals of Programming CS-110. Lecture 2

CS2255 HOMEWORK #1 Fall 2012

Midterm Practice Exam

VARIABLES & ASSIGNMENTS

Week 3: Pointers (Part 2)

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

CMSC 202 Midterm Exam 1 Fall 2015

Review Problems for Final Exam. 1. What is the output of the following program? #include <iostream> #include <string> using namespace std;

C++ PROGRAMMING SKILLS Part 4: Arrays

Transcription:

The American University in Cairo Computer Science & Engineering Department CSCE 106 Dr. Khalil Exam II 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 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 25 2 15 3 15 4 15 5 30 Total 100 1

Question 1 (25 points) Show the output of each of the following program segments: int x = 3, y = 3, z; while (x < 6) y *= ++x; z *= x++ / y--; cout << setw(3) << x << setw(3) << y << setw(3) << z << endl; for ( int c = 1; c <= 45; c++) if (( c % 5 == 0) && ( c % 6!= 0 ) cout << setw(3) << c; cout << endl; const int ten = 10; int d, s = 0, k = 1; int n = 1101; do s= s + k * ( n % ten ); k *= 2; n /= ten; while (n!= 0); cout << The final result is = << s << endl; # include <iostream> # include <iomanip> using namespace std; void main() int a = 15, b = 8, c = 22, 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 << "The first number = " << setw(3) << a << endl; cout << "The second number = " << setw(3) << c << endl; 2

int nm; const int one = 1; const int two = 2; const int three = 3; for ( int n = 1; n < 5; n++) switch(n % three) case 1: nm = one + 2; break; case 2: nm = two + 2; break; default: nm = three + 2; for (int m = 1; m <= n; m++) cout << nm; cout << endl; 3

Question 2 (15 points) a. Write a C++ loop to print the count and sum of all the integer numbers that are divisible by 7 but not divisible by 8 in the range 100 to 1000........................................... b. Using only one variable, write a C++ for-loop to generate the following sequence: 3 5 6 9 10 12 15 18 20 21................................. c. Using only one variable, write a C++ for-loop to generate the following sequence: 2 4 5 8 9 11 14 17 19 20........................... 4

Question 3 (15 points) Write a C++ program that uses only two nested loops to produce the following output: @ 2 3 @ @ @ 2 3 4 5 @ @ @ @ @ 2 3 4 5 6 7 @ @ @ @ @ @ @ 2 3 4 5 6 7 8 9 @ @ @ @ @ @ @ @ @ 5

Question 4 (15 points) The following C++ program takes n temperature readings of a day, computes and displays the average temperature (avgtemp) rounded to the nearest integer), the highest temperature (hightemp) and the number of readings below 0 (countbelow0). The program reads first an integer value for n that should be greater than 1 and not more than 24. Next, the program reads temperature readings one by one and accepts only an integer value between -10 and 42 for each. The program prints all resulting values in fixed format. 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 () int num, temp, hightemp =.., countbelow0 =.; float avgtemp, sumtemp = ; cout << setiosflags ( ios :: fixed ); cout << Enter the number of temperature readings, greater than 0 and not more than 24: ; cin >> num; while (..) cout << Error!!, Invalid value for the number of temperature readings, Please reenter!! ;.; for (.) cout << Enter a temperature reading between -10 and 42: ;.; while (..) cout << Error!!, Invalid temperature reading, Please reenter!! ;.;. ; If ( ) ; If (...) ;.. ; cout << The Average Temperature = <<.. << setw(3) <<.. << endl; cout << The Highest Temperature = << setw(3) <<. << endl; cout << The Lowest Temperature = << setw(3) << << endl; 6

Question 5 (30 points) Write a C++ program to generate a table showing the conversion from Celsius degrees to Farhenheit degrees according to the following formula: Farenheit = (9 / 5) Celsius 32.0 The program reads an integer value for the start Celsius (startc) which should be between -5 and 10 (inclusive), an integer value for the end Celsius (endc) which should not be more than 50, and an integer value for the step Celsius (stepc) which should be greater than 0. The program should enforce the necessary validation on all entered values The computed Farenheit should be printed rounded to the nearest integer in fixed format. The created table should include appropriate header, body and footer. Good Luck 7