Student Name: (in Capital Letters) CSE Introduction to Programming for Engineers and Scientists. Final Exam

Similar documents
Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

BLM2031 Structured Programming. Zeyneb KURT

M1-R4: Programing and Problem Solving using C (JULY 2018)

Data Representation and Storage. Some definitions (in C)

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

C-LANGUAGE CURRICULAM

Character Strings. String-copy Example

Arrays. An array is a collection of several elements of the same type. An array variable is declared as array name[size]

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

A Fast Review of C Essentials Part I

Introduction to C Language (M3-R )

The C++ Language. Arizona State University 1

ECE264 Fall 2013 Exam 3, November 20, 2013

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

ESC101N: Fundamentals of Computing End-sem st semester

High Performance Computing in C and C++

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

Sample Examination. Family Name:... Other Names:... Signature:... Student Number:...

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Data Representation and Storage

Tin học cơ sở 4$ Structures!

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

At this time we have all the pieces necessary to allocate memory for an array dynamically. Following our example, we allocate N integers as follows:

CSC209H Lecture 4. Dan Zingaro. January 28, 2015

ECE264 Spring 2013 Final Exam, April 30, 2013

This exam is to be taken by yourself with closed books, closed notes, no calculators.

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef

BSM540 Basics of C Language

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA === Homework submission instructions ===

COP 3223 Final Review

Chapter 8: Intraprogram Communication. Lecture 8 1

Fundamentals of Programming

C programming basics T3-1 -

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

COP 3223 Final Review

The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

CSE 251 PROJECT 1. Andrew Christlieb. Monday Class AND Friday Class Abstract. Web:

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Programming Fundamentals (CS-302 )

Chapter 10 C Structures, Unions, Bit Manipulations

MARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100

This is CS50. Harvard University Fall Quiz 0 Answer Key

Questions Bank. 14) State any four advantages of using flow-chart

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Kurt Schmidt. October 30, 2018

C Concepts - I/O. Lecture 19 COP 3014 Fall November 29, 2017

b. array s first element address c. base address of an array d. all elements of an array e. both b and c 9. An array elements are always stored in a.

Structures, Operators

CS Spring 05 - MidTerm

Problem 2 Add the two 2 s complement signed 8-bit values given below, and express your answer in decimal.

Here's how you declare a function that returns a pointer to a character:

(13-2) Dynamic Data Structures I H&K Chapter 13. Instructor - Andrew S. O Fallon CptS 121 (November 17, 2017) Washington State University

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Arrays and Pointers. CSE 2031 Fall November 11, 2013

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

CSE351 Winter 2016, Final Examination March 16, 2016

Data Types and Variables in C language

Structures and Pointers

Arrays and Pointers (part 2) Be extra careful with pointers!

FORM 2 (Please put your name and form # on the scantron!!!!)

a) (5 points) What is the output of the following code sequence? int *ptr = 0x1050; printf ("%x\n", ptr--); printf ("%x\n", ptr);

Fundamental of Programming (C)

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008

ECE551 Midterm Version 1

Multiple Choice Questions ( 1 mark)

CS 241 Data Organization Binary Trees

COP 3223 Introduction to Programming with C - Study Union - Spring 2018

PDS Class Test 2. Room Sections No of students

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Repetition Structures

CIS 2107 Computer Systems and Low-Level Programming Fall 2011 Midterm

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

Compiling and Running a C Program in Unix

Practice problems Set 2

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16

Write a C program using arrays and structure

Largest Online Community of VU Students

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

Computers Programming Course 11. Iulian Năstac

Course organization. Course introduction ( Week 1)


Q1: /20 Q2: /30 Q3: /24 Q4: /26. Total: /100

: Principles of Imperative Computation Victor Adamchik. Practice Exam - I

CSE 5A Final Fall 2006

DEPARTMENT OF MATHS, MJ COLLEGE

PES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo

ECE551 Midterm Version 2

COP 3502 Section 2 Exam #2 Version A Spring /23/2017

First of all, it is a variable, just like other variables you studied

Intermediate Programming, Spring 2017*

CS Programming In C

Transcription:

Student Name: (in Capital Letters) CSE 1311 Introduction to Programming for Engineers and Scientists Final Exam Fall 2013 1

1. If count is a properly defined integer variable, the following piece of code: (3 Points) count = 3 ; while (count--) printf ("Looping...\n"); will print "Looping..." (a) Once. (b) Twice. (c) Three times. (d) Four times. (e) Five times. (f) It will keep printing it forever. (g) It will not print anything. 2. Which of the following is a legal statement in C: (3 Points) (a) x < y = z = (u = v); (b) a = b = c = (d > e); (c) m - n - k *= (4 / j); (d) a int b double c; 3. A side effect occurs in programming when (2 Points) a. A global variable is misused, and the error goes throughout the program b. A parameter is passed to the wrong data type. c. A function is called in the wrong order d. All of the above 2

4. An Exit statement causes (3 Points) An Exit statement causes a. The loop to terminate b. The program to terminate c. Returns the control back to the loop d. To skip the next statement only 5. Formal parameters to a function: (3 Points) (a) Must match the actual parameters in number, types and names. (b) Must match the actual parameters in number and names, but not necessarily in types. (c) Must match the actual parameters in number and types, but not necessarily in names. (d) Must not match the actual parameters in their names. 6. The do while loop will (3 points) a. Always be executed at least once b. Be executed only once c. Always be executed until the condition remains true d. None of the above 7. In order to pass a two-dimensional array to a function (3 Points) a. The name of the array in the called function must be exactly the same as the name in the calling function. b. The size of the first dimension must be included in the parameter declaration c. The sizeof command must be called each time. d. All of the above 3

8. Complete the following program segment that will print the value of the counter from 20 to 1. (3 points) int Counter; for( ) { } 9. If a, b, c, d and e are all integer variables, and a is 15, b is 72, c is 31, d is -4, and e is 19, the value of expression e + d / c * b - a / c will be: (4 Points) (a) 15 (b) -8 (c) 19 (d) 7 (e) -2 4

10. Given that the following array, (4 Points) double Dim[4][4]={ {3.65, 8.2, 2.67,7.64}, {51.9, 6.79, 9.8, 91.7}, {5.16, 5.79, 3.84, 2.07}, {4.11, 56.8, 92.7, 13.1} }; What are the values for Dim[0][0], Dim[2][1],Dim[1][2],Dim[3][3]? a. 3.65, 51.9, 6.2, 3.84 b. 3.65, 5.79, 9.8, 13.1 c. 2.07, 3.65, 2.67, 4.11 d. 3.65, 9.8, 5.79, 13.1 11. The typedef function is used to (3 Points) a. Rename a function b. Rename a variable c. Rename a datatype d. All of the above 12. If (a < b) && ((b < 5) (c > b)) && (b > 3) && (!(c > a)) && (c >= b - 1) evaluates to 1, then a must be: (3 Points) 5

13. Given : (4 points) struct Dam { int height; int width; int depth; float spillway; } struct Pipeline { int length; int width; int radius; float valve; } Which of the two structures uses more bytes, or is larger with a sizeof? a. Dam is larger than Pipeline b. Pipeline is larger than Dam c. Dam and Pipeline are the same size 14. In order to dynamically allocate memory in C, use to allocate the memory and to de-allocate the memory. (4 Points) a. memget, memdel b. malloc, falloc c. malloc, free d. free, malloc e. none of the above 15. In order to perform recursion, a function (4 points) a. Has to call itself b. Has to end when the initial conditions are met. c. Has to have the continue statement. d. Both a and c e. Both a and b 6

16. With the following definitions: (4 Points) int first (int a, int b); int second (int c); and the following variable declarations: int my, your, their; the following assignment: my = second ( first (your, their)); (a) is legal in C. (b) is not legal in C. (c) is not legal as is, but it would be legal without the parentheses. (d) is not legal in C, but it would have been legal if it were written in two lines instead of one. 17. Consider the following piece of code (a and b are properly declared integer variables): if (1 >= (a == b)) (4 Points) printf ("Cookoo\n"); (a) This piece of code will always print "Cookoo". (b) This piece of code will not print anything. (c) This piece of code will print "Cookoo" only if values of a and b are same. (d) This piece of code will print "Cookoo" only if values of a and b are different. 18. The case statements of a switch statement can be used with an enumerated type. (4 Points) This is because a. Enumerated types are declared at the beginning of a program. b. Enumerated types act as constant integer values c. Enumerated types are in ascending order d. Case statements continue until a break is found 19. Upon which of the following sets of numbers will a Binary Search work? (4 points) a. 37, 24, 42, 53, 68 b. -29, -35, 43, 55, 63 c. -34, -26, 47, 47, 62 d. All of the above 7

20. Write a short program that will take in from standard input a series of words, and then duplicate each word as in the following: (12 Points) I am happy to be here becomes II amam happyhappy toto bebe herehere Use the strcpy command and the strcat command. The words should be processed inside of a loop. Use strcmp for the word quit, which will make the loop end. (write your program on the following page). 8

9

21. Create a structure that represents a student. The student should have a name, address, and the day, month, and year of birth, and grade point average. Then, use this structure in a short program. Show how to load the structure member by member using the correct notation and library functions. Do not initialize using {}. Then, print out the contents of the structure to screen. (10 Points) 22. What is the following binary number as a hexadecimal? (4 Points) a. A b. 9 c. 72 d. 100 e. A1 1001 10

23. Write a function that takes the addresses of two characters, and swaps the value stored at those integers such that the change remains in effect when the function returns. (pass by reference). (9 Points) 11