UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:

Size: px
Start display at page:

Download "UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:"

Transcription

1 UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed. Examination Period is : 1 hour Answer all questions in the bubble sheet provided to you. You must use a pencil to mark the answer. There are 5 True/False questions and 30 multiple choice questions. Select only one answer for each question. Write your name and student number on the examination paper as well as the bubble sheet and submit both the bubble sheet and the examination paper before you leave the exam hall. Total Marks : 70 Total number of pages : 11 There may be more than one possible answer. Choose the best possible answer. Good Luck!!! 1

2 Section I: Multiple-Choice Questions(30X2=60 marks) 1. What is the output of the following program? #include<stdio.h> void swap(int *, int ); void main(void) int x = 3, y = 4; swap(&x, y); printf( In main, x= %d, y = %d\n, x, y); void swap(int* a, int b) int temp; temp = *a; *a = b; b = temp; a. Will not compile because the & is missing for the function parameter b. b. 4 3 c. 3 4 d. 3 3 e For the function definition of swap given above, which one of the 2 parameters (a and b) is called by reference? a. Both a and b b. Only a c. Only b d. Neither a nor b 2

3 3. Which of the types listed below can be the type of a function output parameter? a. int * b. float * c. char * d. all of the above e. none of the above 4. If the input to the program segment at the right is 85, what is its output? a. A scanf("%d", &s); if (s >= 90) b. B printf("a\n"); else if (s >= 70) c. C printf("c\n"); else if (s >= 80) d. D printf("b\n"); else e. C printf("d\n"); B 5. In function apart defined below, how many of the parameters are considered output parameters? void apart(float x, int *wholep, float *fracp) *wholep = (int)x; *fracp = x - *wholep; a. 0 b. 1 c. 2 d. 3 e. all 3

4 6. What gets stored in variable x after the given if-else is executed. int x = 15; if (x = 5) x = x + 5; else x = x - 5; a. 5 b. 10 c. 15 d. 20 Questions 7 and 8 are based on the following for loop. Assume x is an integer. for (x=5; x<=22; x=x+7) printf( %d,x); 7. What gets printed by the for loop? a b c d What value of x gets printed after the loop ends? a. 22 b. 23 c. 5 d

5 Use the following declaration to answer questions 9,10,11 and 12. int a[50]; 9. Which of the following is a valid instruction that reads a value from the keyboard into array element 9 of array a? a. scanf( %d, &a[i]); b. scanf( %d, &a); c. scanf( %d, a[9]); d. scanf( %d, &a[9]); 10. What is the maximum valid subscript value for array a? a. 0 b. 49 c. 50 d. a[50] e. none of the above 11. Which of the following is a valid instruction that assigns a value of 45 to array element 9 of array a? a. a[i] = 45; b. a[45] = 9; c. a[9] = 45; d. a[] = 45; a. none of the above 12. What is the effect of the following program segment? int i, temp = 0; for (i = 1; i < 50; ++i) if (a[i] > a[0]) temp = temp + 1; a. Arranges the elements of array a in ascending order. b. Counts the number of elements of array a greater than its initial element a[0]. c. Reverses the numbers stored in the array. d. Puts the largest value in the last array position.. 5

6 13. How long does the following code run? for(i=10;i>20;i=i+5) printf( %d,i); a. Never b. Three times c. Forever d. Two times 14.What is printed by the following program fragment? if(3==3 &&!(2==3)) printf( *** ); else printf(??? ); printf(! ); a. *** b. ***! c.??? d.???! 15.What is the value of k after the following statement is executed, given that i and k are integers and i=3 and k = 0. k = ++i; a. 4 b. b. c. 5 d. 3 e. none of the above 6

7 Next four questions will be based on the following program segment. int i, a, j = 5, b = 11; for ( i = 1; i <= 10 ; i = i+ 5) a = j % i ; for ( j = 0; j < 10; j = j + 10) b = b + j; j = j + 1; 16. What is the value of i after the execution of the above code? a. 10 b. 5 c.17 d. 11 e. None of above 17 What is the value of j after the execution of the above code? a. 10 b. 0 c. 5 d. 11 e. None of above 18 What is the value of a after the execution of the above code? a. 10 b. 5 c. 11 d. 2 e. None of above 19. at is the value of b after the execution of the above code? a. 0 b. 26 c. 5 d. 11 e. None of above 20. What value is assigned to x when y is 15.0? if (y< 15.0) if ( y >= 0.0) x = 5 * y; else x = 2 * y; else x = 3 * y; a b c d

8 21. How many times does the following while loop run? float n; int i = 0; printf( Watch out! Here come a bunch of fractions \n ); while (i < 30) n = 1 / i; printf( %f \n,n); printf( That s all, folks!\n ); a. 30 times b. 31 times c. infinite times d. 0 times e. none of the above 22. Which of the following statements can be used to assign values 1,2,3,4,5,6,7 to the array a using for loop. a. for(i=0; i<7; i++) a[i] = i; b. for(i=0; i<7; i++) a[i] = i + 1; c. for(i=1; i<=7; i++) a[i] = i; d. for(i=1; i<=7; i++) a[i] = i + 1; b. none of the above 23. Which of the following is a valid declaration for the array a used in question 22. a. int a[7]; b. int a[1,2,3,4,5,6,7]; c. int a[6]; d. int a[0][7]; 8

9 24. Assuming that a 3-by-4 array is declared as int a[3][4], Which of the following statements will assign a value of 6 to the element at 1 st row and 2 nd column of a. a. a[0,1] = 6; b. a[0][1] = 6; c. a[1,0]=6; d. a[1][0] = 6; e. a[3][4]=6; 25. Given x = 4, y = 3, and operator = 2, what is the final value of x after the following switch statement is executed? switch (operator) case 1: x = x + y; case 2: x = x - y; case 3: x = x * y; case 4: x = x / y; a. 1 b. 3 c d. 7 9

10 Question are based on the program given below : #include <stdio.h> int a=10; int b=4; int c=4; int fun(int,int *,int *); void main(void) int a=9; int b=1; a=fun(a, &b, &c); //end of main int fun(int u, int * v, int * w) *v = a / b; c = *v + a; *w = u + c; a = c + b; b = a + *v; return u + *w; Answer questions after execution of the above program. 26. What is the value of a in main? a. 25 b. 2 c.30 d. 27 e. None of above 27. What is the value of b in main? a. 25 b. 2 c.30 d. 27 e. None of above 28. What is the value of a in Global Area? a. 25 b. 27 c. 21 d What is the value of b in Global Area? a. 25 b. 2 c.30 d. 27 e. None of above 30. What is the value of c in Global Area? a. 25 b. 2 c.30 d. 27 e. None of above 10

11 Section II: State True / False for questions (5 X 2 = 10 marks). (TRUE = A, FALSE = B) 31. The default case is required in a switch statement.false 32. The body of a for loop might not get executed at all.true 33. Sentinel-controlled loops do not know upfront the number of iterations to execute. True 34. Functions cannot have more than one output parameters. False 35. The data-type of an integer array declared as int a[10] is an int. False 11

Quiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.

Quiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007. UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated :October 2nd, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.

More information

UNIVERSITY OF WINDSOR Fall 2006 QUIZ # 1. Examiner:Ritu Chaturvedi Dated : Oct 3rd, Student Name: Student Number:

UNIVERSITY OF WINDSOR Fall 2006 QUIZ # 1. Examiner:Ritu Chaturvedi Dated : Oct 3rd, Student Name: Student Number: UNIVERSITY OF WINDSOR 60-106-01 Fall 2006 QUIZ # 1 Examiner:Ritu Chaturvedi Dated : Oct 3rd, 2006. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) Examination Period is : 1 hour Answer

More information

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number: UNIVERSITY OF WINDSOR 60-106-01 Winter 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated : Feb 7 th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function

More information

AMCAT Automata Coding Sample Questions And Answers

AMCAT Automata Coding Sample Questions And Answers 1) Find the syntax error in the below code without modifying the logic. #include int main() float x = 1.1; switch (x) case 1: printf( Choice is 1 ); default: printf( Invalid choice ); return

More information

Decision Making and Loops

Decision Making and Loops Decision Making and Loops Goals of this section Continue looking at decision structures - switch control structures -if-else-if control structures Introduce looping -while loop -do-while loop -simple for

More information

CGS 3460 Summer 07 Midterm Exam

CGS 3460 Summer 07 Midterm Exam Short Answer 3 Points Each 1. What would the unix command gcc somefile.c -o someotherfile.exe do? 2. Name two basic data types in C. 3. A pointer data type holds what piece of information? 4. This key

More information

Functions. Arash Rafiey. September 26, 2017

Functions. Arash Rafiey. September 26, 2017 September 26, 2017 are the basic building blocks of a C program. are the basic building blocks of a C program. A function can be defined as a set of instructions to perform a specific task. are the basic

More information

Make sure the version number is marked on your scantron sheet. This is Version 1

Make sure the version number is marked on your scantron sheet. This is Version 1 Last Name First Name McGill ID Make sure the version number is marked on your scantron sheet. This is Version 1 McGill University COMP 208 -- Computers in Engineering Mid-Term Examination Tuesday, March

More information

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

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015 CS 141 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015 You may take this test with you after the test, but you must turn in your answer sheet. This test has the following sections:

More information

Arrays and Applications

Arrays and Applications Arrays and Applications 60-141: Introduction to Algorithms and Programming II School of Computer Science Term: Summer 2014 Instructor: Dr. Asish Mukhopadhyay What s an array Let a 0, a 1,, a n-1 be a sequence

More information

M1-R4: Programing and Problem Solving using C (JAN 2019)

M1-R4: Programing and Problem Solving using C (JAN 2019) M1-R4: Programing and Problem Solving using C (JAN 2019) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter

More information

What we have learned so far

What we have learned so far What we have learned so far Straight forward statements Conditional statements (branching) Repeated statements (loop) Arrays One variable many data Problem: Read 10 numbers from the keyboard and store

More information

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015 Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 1 Wednesday, February 11, 2015 Marking Exemplar Duration of examination: 75

More information

Principles of Programming. Chapter 6: Arrays

Principles of Programming. Chapter 6: Arrays Chapter 6: Arrays In this chapter, you will learn about Introduction to Array Array declaration Array initialization Assigning values to array elements Reading values from array elements Simple Searching

More information

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

COP 3223 Introduction to Programming with C - Study Union - Fall 2017 COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

Government Polytechnic Muzaffarpur.

Government Polytechnic Muzaffarpur. Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking

More information

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

COP 3223 Introduction to Programming with C - Study Union - Fall 2017 COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

Pointers and Structure. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Pointers and Structure. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Pointers and Structure Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island 1 Pointer Variables Each variable in a C program occupies space in

More information

CSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming

CSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming CSE101-Lec#18 Multidimensional Arrays Application of arrays Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Defining and processing 1D array 2D array Applications of arrays 1-D array A

More information

Arrays and Strings. Arash Rafiey. September 12, 2017

Arrays and Strings. Arash Rafiey. September 12, 2017 September 12, 2017 Arrays Array is a collection of variables with the same data type. Arrays Array is a collection of variables with the same data type. Instead of declaring individual variables, such

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 06 - Stephen Scott Adapted from Christopher M. Bourke 1 / 30 Fall 2009 Chapter 8 8.1 Declaring and 8.2 Array Subscripts 8.3 Using

More information

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04 Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Topic: Arrays and Strings Practice Sheet #04 Date: 24-01-2017 Instructions: For the questions consisting code segments,

More information

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

Sample Examination. Family Name:... Other Names:... Signature:... Student Number:... Family Name:... Other Names:... Signature:... Student Number:... THE UNIVERSITY OF NEW SOUTH WALES SCHOOL OF COMPUTER SCIENCE AND ENGINEERING Sample Examination COMP1917 Computing 1 EXAM DURATION: 2 HOURS

More information

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler)

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler) 1 Arrays General Questions 1. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would

More information

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #07. Topic: Pointer in C Date:

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #07. Topic: Pointer in C Date: Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Practice Sheet #07 Topic: Pointer in C Date: 23-02-2017 1. Assume the following C variable declaration int *A [10],

More information

Subject: Fundamental of Computer Programming 2068

Subject: Fundamental of Computer Programming 2068 Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find

More information

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++ CSCE 206: Structured Programming in C++ 2017 Spring Exam 3 Monday, April 17, 2017 Total - 100 Points B Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,

More information

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++ CSCE 206: Structured Programming in C++ 2017 Spring Exam 3 Monday, April 17, 2017 Total - 100 Points A Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,

More information

Slides adopted from T. Ferguson Spring 2016

Slides adopted from T. Ferguson Spring 2016 CSE3 Introduction to Programming for Science & Engineering Students Mostafa Parchami, Ph.D. Dept. of Comp. Science and Eng., Univ. of Texas at Arlington, USA Slides adopted from T. Ferguson Spring 06 Pointers

More information

Unit 3 Decision making, Looping and Arrays

Unit 3 Decision making, Looping and Arrays Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.

More information

Pointers. Pointer Variables. Chapter 11. Pointer Variables. Pointer Variables. Pointer Variables. Declaring Pointer Variables

Pointers. Pointer Variables. Chapter 11. Pointer Variables. Pointer Variables. Pointer Variables. Declaring Pointer Variables Chapter 11 Pointers The first step in understanding pointers is visualizing what they represent at the machine level. In most modern computers, main memory is divided into bytes, with each byte capable

More information

Solutions to Assessment

Solutions to Assessment Solutions to Assessment [1] What does the code segment below print? int fun(int x) ++x; int main() int x = 1; fun(x); printf( %d, x); return 0; Answer : 1. The argument to the function is passed by value.

More information

Parameter passing. Programming in C. Important. Parameter passing... C implements call-by-value parameter passing. UVic SEng 265

Parameter passing. Programming in C. Important. Parameter passing... C implements call-by-value parameter passing. UVic SEng 265 Parameter passing Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C implements call-by-value parameter passing int a =

More information

CSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1

CSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1 CSE123 LECTURE 3-1 Program Design and Control Structures Repetitions (Loops) 1-1 The Essentials of Repetition Loop Group of instructions computer executes repeatedly while some condition remains true Counter-controlled

More information

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

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space

More information

Practice Sheet #07 with Solutions

Practice Sheet #07 with Solutions Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Practice Sheet #07 with Solutions Topic: Pointer in C Date: 23-02-2017 1 Assume the following C variable declaration

More information

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points) EECS 183 Fall 2013 Exam 1 Part 1 (80 points) Closed Book Closed Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including

More information

Note: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be.

Note: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be. CS 156 : COMPUTER SYSTEM CONCEPTS TEST 1 (C PROGRAMMING PART) FEBRUARY 6, 2001 Student s Name: MAXIMUM MARK: 100 Time allowed: 45 minutes Note: unless otherwise stated, the questions are with reference

More information

Scope. Scope. Region of a program in which a defined object is visible. Defined Objects. Two types of regions. Variables Functions

Scope. Scope. Region of a program in which a defined object is visible. Defined Objects. Two types of regions. Variables Functions Scope & Repetition Scope Scope Region of a program in which a defined object is visible Defined Objects Variables Functions Two types of regions Blocks Not in a block 2 tj Scope Program Prototype Blocks

More information

Initialisation of an array is the process of assigning initial values. Typically declaration and initialisation are combined.

Initialisation of an array is the process of assigning initial values. Typically declaration and initialisation are combined. EENG212 Algorithms & Data Structures Fall 08/09 Lecture Notes # 2 OUTLINE Review of Arrays in C Declaration and Initialization of Arrays Sorting: Bubble Sort Searching: Linear and Binary Search ARRAYS

More information

At the end of this module, the student should be able to:

At the end of this module, the student should be able to: INTRODUCTION One feature of the C language which can t be found in some other languages is the ability to manipulate pointers. Simply stated, pointers are variables that store memory addresses. This is

More information

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter What you will learn from Lab 7 In this laboratory, you will understand how to use typical function prototype with

More information

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

This exam is to be taken by yourself with closed books, closed notes, no calculators. Student ID CSE 5A Name Final Signature Fall 2004 Page 1 (12) cs5a This exam is to be taken by yourself with closed books, closed notes, no calculators. Page 2 (33) Page 3 (32) Page 4 (27) Page 5 (40) Page

More information

Decisions II. Switch Statement. If else allows a 2 way decision Switch allows for n-way decisions

Decisions II. Switch Statement. If else allows a 2 way decision Switch allows for n-way decisions Switch Statement If else allows a 2 way decision Switch allows for n-way decisions switch(variable){ case val1: statement; case val2: statement; case val3: statement; default: statement; variable must

More information

Control Structure: Loop

Control Structure: Loop Control Structure: Loop Knowledge: Understand the various concepts of loop control structure Skill: Be able to develop a program involving loop control structure 1 Loop Structure Condition is tested first

More information

DECISION MAKING STATEMENTS

DECISION MAKING STATEMENTS DECISION MAKING STATEMENTS If, else if, switch case These statements allow the execution of selective statements based on certain decision criteria. C language provides the following statements: if statement

More information

Arrays. C Types. Derived. Function Array Pointer Structure Union Enumerated. EE 1910 Winter 2017/18

Arrays. C Types. Derived. Function Array Pointer Structure Union Enumerated. EE 1910 Winter 2017/18 C Types Derived Function Array Pointer Structure Union Enumerated 2 tj Arrays Student 0 Student 1 Student 2 Student 3 Student 4 Student 0 Student 1 Student 2 Student 3 Student 4 Student[0] Student[1] Student[2]

More information

Lecture 6 Sorting and Searching

Lecture 6 Sorting and Searching Lecture 6 Sorting and Searching Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 6 77 42 35 12 101 5 1 2 3 4 5 6 5 12 35 42 77 101 There are many algorithms for sorting a list

More information

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 28, 2008 12:20 p.m. 1:50 p.m. Examiners: Jason Anderson, Tom Fairgrieve, Baochun

More information

CSE 5A Final Fall 2006

CSE 5A Final Fall 2006 Student ID cs5f Name Signature CSE 5A Final Fall 2006 Page 1 (18 points) Page 2 (26 points) Page 3 (28 points) Page 4 (16 points) Page 5 (40 points) Page 6 (44 points) Total (172 points = 164 points +

More information

Procedural Programming

Procedural Programming Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Procedural Programming Session Five: Arrays Name: First Name: Tutor: Matriculation-Number: Group-Number: Date: Prof. Dr.Ing. Axel Hunger Dipl.-Ing.

More information

Language comparison. C has pointers. Java has references. C++ has pointers and references

Language comparison. C has pointers. Java has references. C++ has pointers and references Pointers CSE 2451 Language comparison C has pointers Java has references C++ has pointers and references Pointers Values of variables are stored in memory, at a particular location A location is identified

More information

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size]; Arrays An array is a collection of two or more adjacent memory cells, called array elements. Array is derived data type that is used to represent collection of data items. C Array is a collection of data

More information

More Arrays. Last updated 2/6/19

More Arrays. Last updated 2/6/19 More Last updated 2/6/19 2 Dimensional Consider a table 1 2 3 4 5 6 5 4 3 2 12 11 13 14 15 19 17 16 3 1 4 rows x 5 columns 2 tj 2 Dimensional Consider a table 1 2 3 4 5 6 5 4 3 2 12 11 13 14 15 19 17 16

More information

Lecture 16. Daily Puzzle. Functions II they re back and they re not happy. If it is raining at midnight - will we have sunny weather in 72 hours?

Lecture 16. Daily Puzzle. Functions II they re back and they re not happy. If it is raining at midnight - will we have sunny weather in 72 hours? Lecture 16 Functions II they re back and they re not happy Daily Puzzle If it is raining at midnight - will we have sunny weather in 72 hours? function prototypes For the sake of logical clarity, the main()

More information

For questions 4 through 7, select the value assigned to the relevant variable, given the declarations: 3) ) This is not allowed

For questions 4 through 7, select the value assigned to the relevant variable, given the declarations: 3) ) This is not allowed This homework assignment focuses primarily on some of the basic syntax and semantics of C. The answers to the following questions can be determined by consulting a C language reference and/or writing short

More information

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I Last Name (PRINT): First Name (PRINT): University Directory ID (e.g., umcpturtle) I pledge on my honor that I have

More information

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017 Pointers (part 1) EECS 2031 25 September 2017 1 What are pointers? We have seen pointers before. scanf( %f, &inches );! 2 1 Example char c; c = getchar(); printf( %c, c); char c; char *p; c = getchar();

More information

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( Mid Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming

More information

CS 101, Spring 2016 March 22nd Exam 2

CS 101, Spring 2016 March 22nd Exam 2 CS 101, Spring 2016 March 22nd Exam 2 Name: Question 1. [3 points] Which of the following loop statements would most likely cause the loop to execute exactly n times? You may assume that n will be set

More information

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs PDS Lab Section 16 Autumn-2017 Tutorial 3 C Programming Constructs This flowchart shows how to find the roots of a Quadratic equation Ax 2 +Bx+C = 0 Start Input A,B,C x B 2 4AC False x If 0 True B x 2A

More information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

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

Questions Bank. 14) State any four advantages of using flow-chart Questions Bank Sub:PIC(22228) Course Code:-EJ-2I ----------------------------------------------------------------------------------------------- Chapter:-1 (Overview of C Programming)(10 Marks) 1) State

More information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

CS16 Exam #1 7/17/ Minutes 100 Points total

CS16 Exam #1 7/17/ Minutes 100 Points total CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding

More information

Basic and Practice in Programming Lab7

Basic and Practice in Programming Lab7 Basic and Practice in Programming Lab7 Variable and Its Address (1/2) What is the variable? Abstracted representation of allocated memory Having address & value Memory address 10 0x00000010 a int a = 10;

More information

CSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU

CSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU CSE101-lec#12 Designing Structured Programs Introduction to Functions Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Designing structured programs in C: Counter-controlled repetition

More information

WARM UP LESSONS BARE BASICS

WARM UP LESSONS BARE BASICS WARM UP LESSONS BARE BASICS CONTENTS Common primitive data types for variables... 2 About standard input / output... 2 More on standard output in C standard... 3 Practice Exercise... 6 About Math Expressions

More information

Module 6: Array in C

Module 6: Array in C 1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays 1 What are Arrays? Arrays are our first example of structured data. Think of a book with pages numbered 1,2,...,400.

More information

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

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be

More information

Structured programming

Structured programming Exercises 6 Version 1.0, 25 October, 2016 Table of Contents 1. Arrays []................................................................... 1 1.1. Declaring arrays.........................................................

More information

n Group of statements that are executed repeatedly while some condition remains true

n Group of statements that are executed repeatedly while some condition remains true Looping 1 Loops n Group of statements that are executed repeatedly while some condition remains true n Each execution of the group of statements is called an iteration of the loop 2 Example counter 1,

More information

"'"' .;, b) F or ( c = l ; c <= 10,"' c++ ) X { JJ. ~. Computer Programming I COME Midterm Examination. Fall November 2016

'' .;, b) F or ( c = l ; c <= 10,' c++ ) X { JJ. ~. Computer Programming I COME Midterm Examination. Fall November 2016 Group B ~. Computer Programming I COME 103 - Midterm Examination B Fall 2016 21 November 2016 1. Identify and correct the errors in each of the following statements. (Note: There may be more than one error.)

More information

Binary Representation. Decimal Representation. Hexadecimal Representation. Binary to Hexadecimal

Binary Representation. Decimal Representation. Hexadecimal Representation. Binary to Hexadecimal Decimal Representation Binary Representation Can interpret decimal number 4705 as: 4 10 3 + 7 10 2 + 0 10 1 + 5 10 0 The base or radix is 10 Digits 0 9 Place values: 1000 100 10 1 10 3 10 2 10 1 10 0 Write

More information

Decimal Representation

Decimal Representation Decimal Representation Can interpret decimal number 4705 as: 4 10 3 + 7 10 2 + 0 10 1 + 5 10 0 The base or radix is 10 Digits 0 9 Place values: 1000 100 10 1 10 3 10 2 10 1 10 0 Write number as 4705 10

More information

Programming & Data Structure Laboratory. Day 2, July 24, 2014

Programming & Data Structure Laboratory. Day 2, July 24, 2014 Programming & Data Structure Laboratory Day 2, July 24, 2014 Loops Pre and post test loops for while do-while switch-case Pre-test loop and post-test loop Condition checking True Loop Body False Loop Body

More information

Computer Programming Lecture 12 Pointers

Computer Programming Lecture 12 Pointers Computer Programming Lecture 2 Pointers Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics Introduction to Pointers Pointers and

More information

Question 2. [2 points] Which of the following is a correct statement to obtain user input? (Assume that fleems is an int variable.

Question 2. [2 points] Which of the following is a correct statement to obtain user input? (Assume that fleems is an int variable. CS 101, Spring 2016 Feb 23rd Exam 1 Name: Question 1. [2 points] Write a statement(s) to declare a variable named num students that will be used to store the number of students and set the value of the

More information

ESC101N: Fundamentals of Computing End-sem st semester

ESC101N: Fundamentals of Computing End-sem st semester ESC101N: Fundamentals of Computing End-sem 2010-11 1st semester Instructor: Arnab Bhattacharya 8:00-11:00am, 15th November, 2010 Instructions 1. Please write your name, roll number and section below. 2.

More information

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

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

Chapter 7 Functions. Now consider a more advanced example:

Chapter 7 Functions. Now consider a more advanced example: Chapter 7 Functions 7.1 Chapter Overview Functions are logical groupings of code, a series of steps, that are given a name. Functions are especially useful when these series of steps will need to be done

More information

COS 126 General Computer Science Spring Written Exam 1

COS 126 General Computer Science Spring Written Exam 1 COS 126 General Computer Science Spring 2017 Written Exam 1 This exam has 9 questions (including question 0) worth a total of 70 points. You have 50 minutes. Write all answers inside the designated spaces.

More information

Problem: Read 10 numbers from the keyboard and store them

Problem: Read 10 numbers from the keyboard and store them Arrays Problem: Read 10 numbers from the keyboard and store them Problem: Read 10 numbers from the keyboard and store them // solution #1 int a0, a1, a2, a3, a4, a5, a6, a7, a8, a9; printf( Enter a number:

More information

PDS: CS Computer Sc & Engg: IIT Kharagpur 1. for Statement

PDS: CS Computer Sc & Engg: IIT Kharagpur 1. for Statement PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 1 for Statement Another iterative construct in C language is the for-statement (loop). The structure or the syntax of this statement is, for (exp 1 ; exp

More information

'C' Programming Language

'C' Programming Language F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax

More information

only in the space provided. Do the rough work in the space provided for it. The question paper has total 12 pages.

only in the space provided. Do the rough work in the space provided for it. The question paper has total 12 pages. Instructions: Answer all five questions. Total marks = 10 x 2 + 4 x 10 = 60. Time = 2hrs. Write your answer only in the space provided. Do the rough work in the space provided for it. The question paper

More information

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

Q1: /20 Q2: /30 Q3: /24 Q4: /26. Total: /100 ECE 2035(B) Programming for Hardware/Software Systems Fall 2013 Exam Two October 22 nd 2013 Name: Q1: /20 Q2: /30 Q3: /24 Q4: /26 Total: /100 1/6 For functional call related questions, let s assume the

More information

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 20, 2011 6:15 p.m. 8:00 p.m. (105 minutes) Examiners: J. Anderson, T. Fairgrieve,

More information

Outline Introduction Arrays Declaring Arrays Examples Using Arrays Passing Arrays to Functions Sorting Arrays

Outline Introduction Arrays Declaring Arrays Examples Using Arrays Passing Arrays to Functions Sorting Arrays Arrays Outline 1 Introduction 2 Arrays 3 Declaring Arrays 4 Examples Using Arrays 5 Passing Arrays to Functions 6 Sorting Arrays 7 Case Study: Computing Mean, Median and Mode Using Arrays 8 Searching Arrays

More information

Arrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array

Arrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array Arrays Array is a collection of similar data types sharing same name or Array is a collection of related data items. Array is a derived data type. Char, float, int etc are fundamental data types used in

More information

Do not start the test until instructed to do so!

Do not start the test until instructed to do so! Fall 1999 Page 1 of 10 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense. Print

More information

ECE15: Introduction to Computer Programming Using the C Language Lecture 6: Arrays

ECE15: Introduction to Computer Programming Using the C Language Lecture 6: Arrays ECE15: Introduction to Computer Programming Using the C Language Lecture 6: Arrays A. Orlitsky and A. Vardy, based in part on slides by S. Arzi, G. Ruckenstein, E. Avior, S. Asmir, and M. Elad Outline

More information

This is CS50. Harvard University Fall Quiz 0 Answer Key

This is CS50. Harvard University Fall Quiz 0 Answer Key Quiz 0 Answer Key Answers other than the below may be possible. Binary Bulbs. 0. Bit- Sized Questions. 1. Because 0 is non- negative, we need to set aside one pattern of bits (000) for it, which leaves

More information

COP 2000 Introduction to Computer Programming Mid-Term Exam Review

COP 2000 Introduction to Computer Programming Mid-Term Exam Review he exam format will be different from the online quizzes. It will be written on the test paper with questions similar to those shown on the following pages. he exam will be closed book, but students can

More information

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine

More information

return return else return

return return else return compare0.c 1 // Compares two strings' addresses 4 #include 5 6 int main(void) 7 { 8 // get two strings 9 string s = get_string("s: "); 10 string t = get_string("t: "); 11 1 // compare strings'

More information

Indian Institute of Technology Kharagpur Programming and Data Structures (CS10001) Autumn : Mid-Semester Examination

Indian Institute of Technology Kharagpur Programming and Data Structures (CS10001) Autumn : Mid-Semester Examination Indian Institute of Technology Kharagpur Programming and Data Structures (CS10001) Autumn 2017-18: Mid-Semester Examination Time: 2 Hours Full Marks: 60 INSTRUCTIONS 1. Answer ALL questions 2. Please write

More information