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

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

BSc (Hons) Computer Science. with Network Security. Examinations for / Semester1

BEng (Hons) Telecommunications. Examinations for 2016 / Semester 2

BEng (Hons) Electronic Engineering. BEng (Hons) Telecommunications. Examinations for / Semester 2

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

Getting started with C++ (Part 2)

Introduction to Computer Science Midterm 3 Fall, Points

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

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

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

Programming Language. Functions. Eng. Anis Nazer First Semester

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.

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

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

CPT101- Principles of Programming

pointers + memory double x; string a; int x; main overhead int y; main overhead

CSCE Practice Midterm. Data Types

Arrays. Week 4. Assylbek Jumagaliyev

Program Organization and Comments

Week 3: Pointers (Part 2)

Exercise 1.1 Hello world

CMSC 202 Midterm Exam 1 Fall 2015

Chapter 6: User-Defined Functions. Objectives (cont d.) Objectives. Introduction. Predefined Functions 12/2/2016

Short Notes of CS201

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

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

CS201 - Introduction to Programming Glossary By

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

Lab 12 Object Oriented Programming Dr. John Abraham

Outline. Functions. Functions. Predefined Functions. Example. Example. Predefined functions User-defined functions Actual parameters Formal parameters

Largest Online Community of VU Students

EXAMINATION FOR THE BSC (HONS) INFORMATION SYSTEMS; BSC (HONS) INFORMATION TECHNOLOGY & BSC (HONS) COMPUTER SCIENCE; YEAR 1

C++ For Science and Engineering Lecture 15

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

BSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2

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

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

EE 109 Lab 8a Conversion Experience

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

Fundamentals of Programming. Lecture 19 Hamed Rasifard

Chapter 9: Pointers Co C pyr py igh i t gh Pear ea so s n n E ducat ca io i n, n Inc. n c.

CSCE Practice Midterm. Data Types

CSE 333 Final Exam June 6, 2017 Sample Solution

LAB 4.1 Relational Operators and the if Statement

9. Arrays. Compound Data Types: type name [elements]; int billy [5];

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

Today USING POINTERS. Functions: parameters and arguments. Todaywewilllookattopicsrelatingtotheuseofpointers

CSCE121: Introduction to Program Design and Concepts Practice Questions for Midterm 1

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

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

Pointers II. Class 31

B.Sc. (Hons.) Computer Science I B.Sc. (Hons.) Electronics. (i) Runtime polymorphism and compile time polymorphism

Computer Engineering Department CMPE110 Midterm Sample Questions, 2017/ Fall

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

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

Pointers. Variable Declaration. Chapter 10

CS2141 Software Development using C/C++ C++ Basics

File I/O Christian Schumacher, Info1 D-MAVT 2013

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

Ch 6. Functions. Example: function calls function

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

WARM UP LESSONS BARE BASICS

BSc (Hons) Computer Science with Network Security/ BSc (Hons) Software Engineering/ BSc (Hons) Web Technologies. Examinations for 2016 Semester 1

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

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

Code No: R Set No. 1

Object Oriented Design

BEng. (Hons) Telecommunications. Examinations for / Semester 2

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

Study Guide for Test 2

System Design and Programming II

COMP322 - Introduction to C++ Lecture 01 - Introduction

Chapter 2: Basic Elements of C++

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

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

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

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

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

CSci 1113 Final. Name: Student ID:

Introduction to C++ Introduction to C++ 1

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

Programming Language. Control Structures: Selection (switch) Eng. Anis Nazer First Semester

More loops Ch

MM1_ doc Page E-1 of 12 Rüdiger Siol :21

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

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

Agenda / Learning Objectives: 1. Map out a plan to study for mid-term Review the C++ operators up to logical operators. 3. Read about the tips

8. The C++ language, 1. Programming and Algorithms II Degree in Bioinformatics Fall 2017

VARIABLES & ASSIGNMENTS

CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings

Introduction to C++ (Extensions to C)

CSCE 206: Structured Programming in C++

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

Definition Matching (10 Points)

Introduction to C++ 2. A Simple C++ Program. A C++ program consists of: a set of data & function definitions, and the main function (or driver)

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

Topics. bool and string types input/output library functions comments memory allocation templates classes

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

11. Arrays. For example, an array containing 5 integer values of type int called foo could be represented as:

Transcription:

BEng (Hons) Electronic Engineering Cohort: BEE/10B/FT Resit Examinations for 2016-2017 / Semester 1 MODULE: Programming for Engineers MODULE CODE: PROG1114 Duration: 3 Hours Instructions to Candidates: 1. Answer all questions. 2. Questions may be answered in any order but your answers must show the question number clearly. 3. Always start a new question on a fresh page. 4. All questions do not carry equal marks. 5. Total marks 100. This question paper contains 4 questions and 6 pages. Page 1 of 6

QUESTION 1: (25 MARKS) ANSWER ALL QUESTIONS (a) The following code segments are erroneous. Correct the error(s) in each segment of code below. i) double mainint = 3000.0; double int = 1.016 * mainint; cout<< setprecision(2) << fixed; cout<< "The calculated amount is" << int; ii) int t; cout << "Enter a number: "; cin << T; cout << "Your number is " << t; iii) iv) x = 1; while( x <= 10 ); x++; string* sub1; string* sub2; *sub1 = Programming ; sub1 = sub2; v) int* x= &10; (10 marks) Page 2 of 6

Write a block of C++ code that prints out the odd numbers 1 through 999. You do not need to write a full program. Explain the difference between the two expressions below. (3 marks) x = 2 and x == 2 (d) (e) (2 marks) What does the function fixed in the <iomanip> library do? Give an example to support your answer. (2 marks) Highlight the difference between compile errors and runtime errors. Give a specific example of each type of error. (f) Rewrite the following for loop as a do-while loop. (4.5 marks) for (int x=0; x<100; x++) cout << x << " "; (3.5 marks) QUESTION 2: (25 MARKS) (a) Write a function, using switch statement, that converts a char letter grade into its numerical equivalent as per grading system below: A=25.0 B=20.0 C=15.0 D=10.0 F=0.0 The program should use the following header line double grade2num (char grade) The program should return the value 0.0 if it receives a character besides A, B, C, D and F. Page 3 of 6

The binary search uses the divide and conquer strategy. It repeatedly divides the array into two pieces and then searches the piece that could contain the target value. Write a recursive binarysearch function to perform the binary search of an array. The function should receive an integer array, the starting subscript, ending subscript and search key as arguments. If the search key is found, the function should return the array subscript; otherwise, it should return -1. Write the output of the following program. (10 marks) void something (int* p, int* &q) { *p = 5; p += 3; *p += *q; cout << *p << << *q << \n ; q--; return; int main() { int a[4] = {10,20,30,40; int* b = a; int* c = &a[2]; something (b, c); cout << *b << << *c; return 0; (d) Write a program that reads all data from the file experiment.txt, containing integers, and display them on the screen. (7 marks) QUESTION 3: (25 MARKS) (a) Give two advantages of using functions to modularise a program? (2 marks) Page 4 of 6

Convert the following if/else sequence to a switch statement. int x; cin >> x; if (x == 2) cout << "x=2"; else if (x==3 x==5) { cout << "x=3 or 5"; x++; else if (x==4) cout << "x=4"; else cout << "Else."; Briefly explain the difference between passing parameters by value and passing parameters by reference. (d) Write the output of the following program. Assume that p and x are allocated addresses 06FD4 and 06FD8, respectively. #include <iostream> using namespace std; int main () { int *p; int x=37; cout<< Line 1: x = <<x<<endl; p=&x; cout<< Line 3: *p= <<*p<<, x = <<x<<endl; *p=58; cout<< Line 5: *p= <<*p<<, x = <<x<<endl; cout<< Line 6: Address of p = <<&p<<endl; cout<< Line 7: Value of p = <<p<<endl; cout<< Line 8: Value of the location pointed to by p = <<*p<<endl; cout<< Line 9: Address of x = <<&x<<endl; cout<< Line 10: Value of x = <<x<<endl; return 0; (10 marks) Page 5 of 6

(e) With appropriate example distinguish between static binding and dynamic binding? (5 marks) QUESTION 4: (25 MARKS) (a) Write detailed notes on Classes and Objects. Your answer should include the following: (i) Class and object definitions, (ii) Class declaration, (iii) Levels of restriction, (iv) Member variables and functions, (9 marks) i) What is a queue? (2 marks) ii) Write the class interface for a node and for a queue using the predefined node in C++. A linked list may be represented as follows: (8 marks) The list starts with a pointer Head, which points to the first node and the next field of each node points to the next node. Diagrammatically show the steps i) to add a node at the beginning of the list. ii) to add a node at the end of the list. iii) to add a node in between two nodes. (6 marks) ***END OF QUESTION PAPER*** Page 6 of 6