CMPSC 16 PRACTICE MIDTERM 2 SUMMER All programming questions in this exam should be answered based on the programming language C.

Size: px
Start display at page:

Download "CMPSC 16 PRACTICE MIDTERM 2 SUMMER All programming questions in this exam should be answered based on the programming language C."

Transcription

1 CMPSC 16 PRACTICE MIDTERM 2 SUMMER 2014 All programming questions in this exam should be answered based on the programming language C.

2 Sample Exam Problem. Know the definitions of the following terms and be able to match them with a desciptive phrase (as in exam 1). abtraction, reusability, function invocation, function definition, function prototype, formal parameters, actual prameters, call-by-value, scope, global variable, local variable, recursive function, array, dereference operator, address operator, pointer, dynamic memory, static memory. Sample Exam Problem. Consider an input file input.txt with the following content: CS 16 8/ The first character in the file is C and the last character is.. There is a blank (space) character after "CS". Consider the code segment below. Show the contents of the file output.txt after this code is executed by completing the output shown below: CODE SEGMENT: #include <stdio.h> int main(void) { char c; int value = 0; int i; FILE * input, * output; input = fopen("input.txt", "r"); output = fopen("output.txt", "w"); fscanf(input, "%c", &c); fprintf(output, "c: %c\n\n", c); fscanf(input, "%d", &value); fprintf(output, "value: %d\n\n", value); fscanf(input, "%c", &c); fscanf(input, "%d", &value); fprintf(output, "value: %d\n\n", value); OUTPUT: c: value: value: c: value: for(i = 0; i <= 6; i++) fscanf(input, "%c", &c); fprintf(output, "c: %c\n\n", c); fscanf(input, "%d", &value); fprintf(output, "value: %d\n\n", value);

3 Sample Exam Problem. Show the contents of the array x after all the statements in the following code segment are executed. List the contents of x starting with the first element of the array, and write a question mark? if the contents are not defined. CODE SEGMENT: CONTENTS OF x: int x[5]; x[2] = 1; x[3] = 5; x[x[2]] = x[2] * 2; x[5 - x[1]] = 9; /* What are the contents of x here? */ Sample Exam Problem. Write a C programming statement using malloc that will declare a pointer named xp which points to a dynamically allocate block of memory with space for 10 integer values. Fill in your answer on the blank line. (Hint: see the lab on pointers). int * xp =

4 Sample Exam Problem. Given the following declarations, show the results of evaluating the following expressions. If the expression accesses a section of memory that contains unknown values write?. (Hint: for studying, try it out in ch) int y[6] = { 2,3,5,7,11,13; int *yp = &y[2]; EXPRESSION: *y VALUE: *yp *(yp + y[0]) *yp + y[0] yp[4] + 1

5 Sample Exam Problem. Given the following code segment, show the output that will be generated by this code by completing the partial output shown below. CODE SEGMENT: #include<stdio.h> int value = 0; void func1(int x) { x = 5; void func2(int *x) { *x = 10; void func3(int x) { value = x; int main(void) { int x = 0; func1(x); printf("x is: %d\n\n", x); func2(&x); printf("x is: %d\n\n", x); OUTPUT: x is: x is: value is: value is: x is: value is: value is: func1(value); printf("value is: %d\n\n", value); func2(&value); printf("value is: %d\n\n", value); func3(5); printf("x is: %d\n\n", x); printf("value is: %d\n\n", value); func2(&value); func3(value - 1); printf("value is: %d\n\n", value);

6 Sample Exam Problem Write a code segement to compute the sum of three 3-by-3 matrices. We want to compute D = A + B + C. Fill in the missing portion below. #include<stdio.h> int main(){ int A[3][3] = {{-1,3,6,{19, -8-1,{-8, -6, 1; int B[3][3] = {{12, 0, 0, {5, 2, -1, {6,5,7; int C[3][3] = {{9,8,7, {1,2,3, {5,4,6; int D[3][3]; int i, j, n = 3; // Compute D = A + B + C // Fill in the missing code here // print D printf("\nmatrix D = A + B + C:\n"); for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ printf("%3i ", D[i][j]); printf("\n"); The program should produce the following expected output: Matrix D = A + B + C:

7 Sample Exam Problem. Consider the imaginary memory layout below in which addresses are four digit integers and all values stored in memory are represented as positive integers. Assume that an integer takes up 4 bytes, so that adjacent memory addresses differ by 4. So, incrementing an address by 1 results in an address that is 4 bytes away. For example, &y is 1012, &y + 1 is 1016, &y + 2 is 1020, and so on. The addresses, memory contents, and variable names associated with particular memory blocks are shown in the table. Address Memory Contents Variable x y z Fill in the following table showing the value of the given expressions. EXPRESSION: x VALUE: *1008 &y *&y &x+1 *z+4 **(&x+4) *(&z+1)

8 Sample Exam Problem. Write a function that searches for a value in an array. The function will take three arguments: 1) an integer value that is greater than 0 and indicates the size of the array, 2) an integer array of that size, and 3) an integer value that we would like to search. The function should return an integer value. It should return -1 if the value that is being searched is not in the array. Otherwise, it should return the position of the value in the array (return 0 for the first position). Assume that there are no duplicates in the list - every item is unique. #include <stdio.h> int findval(int size, int values[], int value); int main(void) { int arraysize =...; int result; int value =...; int myarray[] =...; result = findval(arraysize, myarray, value); if (result == -1) printf("the value %d is not in the list.\n", value); else printf("the value %d is at position %d in the list.\n", value, result); int findval(int size, int values[], int value) { int result, i; /* write the missing part below */ return result;

9 Sample Exam Problem. Write a recursive function that adds all the elements in an array. The function will take two arguments, 1) an integer value that is greater than 0 and indicates the size of the array, and 2) an integer array of that size. The function should return an integer value that is the sum of the elements in the array. The function should add elements of the input array using recursion and should not use a loop. #include <stdio.h> int recursivesum(int size, int values[]); int main(void) { int arraysize =...; int result; int myarray[] =...; result = recursivesum(arraysize, myarray); printf("the sum is %d\n", result); int recursivesum(int size, int values[]) { /* write the missing part below */

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: IMPORTANT INSTRUCTIONS: 1. Question Paper in English and Hindi and Candidate can choose any one language. 2. In case of discrepancies in

More information

1 (1x17 =17 points) 2 (21 points) 3 (5 points) 4 (3 points) 5 (4 points) Total ( 50points) Page 1

1 (1x17 =17 points) 2 (21 points) 3 (5 points) 4 (3 points) 5 (4 points) Total ( 50points) Page 1 CS 1621 MIDTERM EXAM 1 Name: Problem 1 (1x17 =17 points) 2 (21 points) 3 (5 points) 4 (3 points) 5 (4 points) Total ( 50points) Score Page 1 1. (1 x 17 = 17 points) Determine if each of the following statements

More information

Pointers and dynamic memory management in C

Pointers and dynamic memory management in C Pointers and dynamic memory management in C Jakob Rieck Proseminar C - 2014 Contents 1 Introduction 2 2 Pointers 4 2.1 Declaration & Initialization................... 5 2.2 Using pointers..........................

More information

Final Exam Review. CS 1428 Fall Jill Seaman. Final Exam

Final Exam Review. CS 1428 Fall Jill Seaman. Final Exam Final Exam Review CS 1428 Fall 2011 Jill Seaman 1 Final Exam Friday, December 9, 11:00am to 1:30pm Derr 241 (here) Closed book, closed notes, clean desk Comprehensive (covers entire course) 25% of your

More information

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11 Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11 In this lab, you will first learn how to use pointers to print memory addresses of variables. After that, you will learn

More information

1. Constants. 2. Variables. 3. Reserved words or key words. 4. Constants. Character set in C

1. Constants. 2. Variables. 3. Reserved words or key words. 4. Constants. Character set in C Character set in C We should use only the following characters in writing a C program. These characters can be combined to create C words. Alphabet: A, B, C, D.. Z, a, b, c, d..z Numeric digits: 0, 1,

More information

READ EACH QUESTION CAREFULLY.

READ EACH QUESTION CAREFULLY. UNIVERSITY COLLEGE DUBLIN NATIONAL UNIVERSITY OF IRELAND, DUBLIN An Colaiste Ollscoile Baile Atha Cliath Ollscoil na heireann, Baile Atha Cliath SUMMER EXAMINATIONS 2003 FIRST EXAMINATION IN ENGINEERING

More information

MIT Aurangabad FE Computer Engineering

MIT Aurangabad FE Computer Engineering MIT Aurangabad FE Computer Engineering Unit 1: Introduction to C 1. The symbol # is called a. Header file c. include b. Preprocessor d. semicolon 2. The size of integer number is limited to a. -32768 to

More information

Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c

Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection

More information

C for Java Programmers

C for Java Programmers C for Java Programmers CS 414 / CS 415 Niranjan Nagarajan Department of Computer Science Cornell University niranjan@cs.cornell.edu Original Slides: Alin Dobra Why use C instead of Java Intermediate-level

More information

Example Solution to Exam in EDA150 C Programming

Example Solution to Exam in EDA150 C Programming Example Solution to Exam in EDA150 C Programming Janurary 12, 2011, 14-19 Inga hjälpmedel! Examinator: Jonas Skeppstedt, tel 0767 888 124 30 out of 60p are needed to pass the exam. General Remarks A function

More information

Basic C Syntax. Comp-206 : Introduction to Software Systems Lecture 10. Alexandre Denault Computer Science McGill University Fall 2006

Basic C Syntax. Comp-206 : Introduction to Software Systems Lecture 10. Alexandre Denault Computer Science McGill University Fall 2006 Basic C Syntax Comp-206 : Introduction to Software Systems Lecture 10 Alexandre Denault Computer Science McGill University Fall 2006 Next Week I'm away for the week. I'll still check my mails though. No

More information

Short Notes on Dynamic Memory Allocation, Pointer and Data Structure

Short Notes on Dynamic Memory Allocation, Pointer and Data Structure Short Notes on Dynamic Memory Allocation, Pointer and Data Structure 1 Dynamic Memory Allocation in C/C++ Motivation /* a[100] vs. *b or *c */ Func(int array_size) double k, a[100], *b, *c; b = (double

More information

Standard printing function in C is printf Prints everything numbers, strings, etc. May be complex to use. Standard C library is called libc

Standard printing function in C is printf Prints everything numbers, strings, etc. May be complex to use. Standard C library is called libc Arrays and Structs and Pointers, Oh My! Programming in C Input and output Using printf Standard input and output Pointers Arrays Structures Combining these things together Arrays and Structs and Pointers,

More information

Comp Arrays and Pointers. Class Notes. T h e G r o u p o f T h r e e

Comp Arrays and Pointers. Class Notes. T h e G r o u p o f T h r e e Comp 2401 Arrays and Pointers Class Notes 2013 T h e G r o u p o f T h r e e Introduction To Arrays: In C programming, one of the frequently problem is to handle similar types of data. For example: if

More information

A Rudimentary Intro to C programming

A Rudimentary Intro to C programming A Rudimentary Intro to C programming Wayne Goddard School of Computing, Clemson University, 2008 Part 4: Strings and Pointers 18 Strings.................................... D1 19 String Functions..............................

More information

Fundamentals of Computer & Programming in C Short-answer type questions

Fundamentals of Computer & Programming in C Short-answer type questions Fundamentals of Computer & Programming in C Short-answer type questions Section- A i. What is a computer system? Draw the block diagram of computer. ii. Differentiate between Real Time Operating System

More information

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK (2110003) [F.Y.B.E.

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK (2110003) [F.Y.B.E. SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK Subject: Computer Programming and Utilization (2110003) [F.Y.B.E.: ALL BRANCHES] Unit 1

More information

arrays C Programming Language - Arrays

arrays C Programming Language - Arrays arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

More information

C AND C++ PROGRAMMING

C AND C++ PROGRAMMING C AND C++ PROGRAMMING Bharathidasan University A Courseware prepared by University Informatics Centre Part I - Programming in C Getting Started This courseware is intended to be an introduction to C programming

More information

C Programming Lab. 1DT032: Advanced Computer Science Studies in Sweden 1DT086: Introduction to Studies in Embedded Systems Uppsala University

C Programming Lab. 1DT032: Advanced Computer Science Studies in Sweden 1DT086: Introduction to Studies in Embedded Systems Uppsala University C Programming Lab 1DT032: Advanced Computer Science Studies in Sweden 1DT086: Introduction to Studies in Embedded Systems Uppsala University September 3, 2015 Submitting Assignments, and Requirements for

More information

BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE

BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE Certificate in Advanced Programming - C++ Language Page 1 of 7 BHARATHIAR UNIVERSITY: COIMBATORE 641046 CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++

More information

C A short introduction

C A short introduction About these lectures C A short introduction Stefan Johansson Department of Computing Science Umeå University Objectives Give a short introduction to C and the C programming environment in Linux/Unix Go

More information

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering Cohort: BCNS/07/FT- BIS/07/FT- BIS/06/FT -BM/07/FT BSE/07/FT/PT-

More information

SYSTEMS PROGRAMMING C++ INTRODUCTION

SYSTEMS PROGRAMMING C++ INTRODUCTION Faculty of Computer Science / Institute of Systems Architecture / Operating Systems SYSTEMS PROGRAMMING C++ INTRODUCTION Alexander Warg WHY C++? C++ is the language that allows to express ideas from the

More information

Tutorial No. 8 - Solution (Strings and User Defined Functions)

Tutorial No. 8 - Solution (Strings and User Defined Functions) Tutorial No. 8 - Solution (Strings and User Defined Functions) 1. Explain strcat( ), strcpy( ),strncmp( ) and strstr( ) string manipulation function. [6] strcat() Function: The strcat function joins two

More information

CS 261 Data Structures. Introduction to C Programming

CS 261 Data Structures. Introduction to C Programming CS 261 Data Structures Introduction to C Programming Why C? C is a simple language, C makes it easier to focus on important concepts C is a lower level, imperative language Lays groundwork for many other

More information

strsep exercises Introduction C strings Arrays of char

strsep exercises Introduction C strings Arrays of char strsep exercises Introduction The standard library function strsep enables a C programmer to parse or decompose a string into substrings, each terminated by a specified character. The goals of this document

More information

C Primer. Fall Introduction C vs. Java... 1

C Primer. Fall Introduction C vs. Java... 1 CS 33 Intro Computer Systems Doeppner C Primer Fall 2016 Contents 1 Introduction 1 1.1 C vs. Java.......................................... 1 2 Functions 1 2.1 The main() Function....................................

More information

The if-statement. Simple and compound statements. The if-statement comes in two forms: Simple statements:

The if-statement. Simple and compound statements. The if-statement comes in two forms: Simple statements: 1 2 Simple and compound s The if- Simple s: E.g.: expression; Various jumps : break, goto, continue, return. k = a * p + 3; printf("k = %d\n", k); 1 + 2; ; The if- comes in two forms: or E.g.: if (expression)

More information

GTU Questions. Computer Programming & Utilization. Chief Course Coordinator Prof. Mitul K.Patel. (Head of Department & Assistant Professor)

GTU Questions. Computer Programming & Utilization. Chief Course Coordinator Prof. Mitul K.Patel. (Head of Department & Assistant Professor) GTU Questions Computer Programming & Utilization Chief Course Coordinator Prof. Mitul K.Patel (Head of Department & Assistant Professor) Course Coordinator Prof. Vrutti D. Shah (Assistant Professor) Lab

More information

INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

More information

Common C Errors. Compiled by: Leela Kamalesh Yadlapalli

Common C Errors. Compiled by: Leela Kamalesh Yadlapalli Common C Errors Compiled by: Leela Kamalesh Yadlapalli This document shows some of the common errors and warnings that you may encounter during this class. Always remember to use the Wall option if you

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse

More information

The char Data Type. Character and String Processing. Another Example /* Capitalize all lowercase letters */ while ((c = getchar())!

The char Data Type. Character and String Processing. Another Example /* Capitalize all lowercase letters */ while ((c = getchar())! Character and String Processing CSE 130: Introduction to C Programming Spring 2005 The char Data Type A char value can be thought of as either a character or a small integer printf( %d, a ); /* prints

More information

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

Problem 2 Add the two 2 s complement signed 8-bit values given below, and express your answer in decimal. Problem 1 Recall the definition of root in project 1. (The declaration of struct entrynode appears below.) struct entrynode * root; Give the type of each of the following expressions. The answer may be

More information

Illustration 1: Diagram of program function and data flow

Illustration 1: Diagram of program function and data flow The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline

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 27, 2009 12:20 p.m. 1:50 p.m. Examiners: J. Anderson, T. Fairgrieve, H. Ghaderi,

More information

Introduction to C Programming S Y STEMS

Introduction to C Programming S Y STEMS Introduction to C Programming CS 40: INTRODUCTION TO U NIX A ND L I NUX O P E R AT ING S Y STEMS Objectives Introduce C programming, including what it is and what it contains, which includes: Command line

More information

printf() Standard Library Function printf()

printf() Standard Library Function printf() printf() Standard Library Function Used to write text to the "standard output" Normally a computer monitor or printer Often the UART in embedded systems SIM Uart1 window in MPLAB SIM printf() Standard

More information

ZDS II for ez80acclaim!: Calling C Functions from Assembly and Vice Versa AN

ZDS II for ez80acclaim!: Calling C Functions from Assembly and Vice Versa AN ZDS II for ez80acclaim!: Calling C Functions from Assembly and Vice Versa AN033301-0711 Abstract Discussion In certain situations, developers find that they must combine source code files written in Assembly

More information

The main features of First Generation are:

The main features of First Generation are: MODEL SOLUTION AS -4016 B.Te ch (First Semester) course A INTRODUCTION TO COMPUTER PROGRAMMING ANS 1 : i. Electrically Erasable Programmable Read Only Memory ii. Four Generation iii. c iv. 8 v. High Level

More information

Parameter Passing. Standard mechanisms. Call by value-result Call by name, result

Parameter Passing. Standard mechanisms. Call by value-result Call by name, result Parameter Passing Standard mechanisms Call by value Call by reference Other methods Call by value-result Call by name, result Terms Function definition where the details of the function are presented (type,

More information

Arrays. Arrays, Argument Passing, Promotion, Demotion

Arrays. Arrays, Argument Passing, Promotion, Demotion Arrays Arrays, Argument Passing, Promotion, Demotion Review Introduction to C C History Compiling C Identifiers Variables Declaration, Definition, Initialization Variable Types Logical Operators Control

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

MPI and C-Language Seminars 2010

MPI and C-Language Seminars 2010 MPI and C-Language Seminars 2010 Seminar Plan (1/3) Aim: Introduce the C Programming Language. Plan to cover: Basic C, and programming techniques needed for HPC coursework. C-bindings for the Message Passing

More information

C Programming, Chapter 1: C vs. Java, Types, Reading and Writing

C Programming, Chapter 1: C vs. Java, Types, Reading and Writing C Programming, Chapter 1: C vs. Java, Types, Reading and Writing T. Karvi August 2013 T. Karvi C Programming, Chapter 1: C vs. Java, Types, Reading and Writing August 2013 1 / 1 C and Java I Although the

More information

Reading Assignment. Main Program in C. K.N. King Chapter 2. K.N. King Chapter 3. K.N. King Chapter 4. K.N. King Chapter 7. Our first C program

Reading Assignment. Main Program in C. K.N. King Chapter 2. K.N. King Chapter 3. K.N. King Chapter 4. K.N. King Chapter 7. Our first C program Reading Assignment Main Program in C In C the main program is a function called main The body of the function is enclosed in left ( ) and right ( ) curly braces. K.N. King Chapter 2 K.N. King Chapter 3

More information

CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16

CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16 CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16 Basics of C Remark: Skim Chapters 1 through 6 of Deitel & Deitel. You will notice the following: C is (more or less) a subset of Java. (So, you are

More information

An Introduction to C and Parallel Programming with Applications. Derrick C. Cerwinsky Craig C. Douglas Mookwon Seo Xiaoban Wu University of Wyoming

An Introduction to C and Parallel Programming with Applications. Derrick C. Cerwinsky Craig C. Douglas Mookwon Seo Xiaoban Wu University of Wyoming An Introduction to C and Parallel Programming with Applications Derrick C. Cerwinsky Craig C. Douglas Mookwon Seo Xiaoban Wu University of Wyoming January 15, 2014 ii Contents 1 Introduction 1 1.1 First

More information

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 603 203 DEPARTMENT OF COMPUTER APPLICATIONS QUESTION BANK IN REVISED BLOOM S TAXONOMY

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 603 203 DEPARTMENT OF COMPUTER APPLICATIONS QUESTION BANK IN REVISED BLOOM S TAXONOMY ACADEMIC YEAR: 0 7 VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 0 0 SEMESTER: ODD BRANCH: MCA YEAR: I SEMESTER: I SUBJECT CODE AND NAME: MC70 Problem Solving and Programming NAME OF THE FACULTY

More information

Thinking in C. Darin Brezeale. March 25, 2010

Thinking in C. Darin Brezeale. March 25, 2010 Thinking in C Darin Brezeale March 25, 2010 NOTE: This is definitely a work in progress. 1 Introduction One of the most difficult parts of learning to program is knowing how to deconstruct a problem in

More information

3/13/2012. Esc101: Strings. String input and output. Array of characters: String

3/13/2012. Esc101: Strings. String input and output. Array of characters: String Esc101: Strings Instructor: Krithika Venkataramani Semester 2, 2011-2012 The contents of most of these slides are from the lecture slides of Prof. Arnab Bhattacharya 1 2 Array of characters: String String

More information

,!7IA3C1-dcahfj!:t;K;k;K;k. Addison-Wesley s JavaScript Reference Card. Kathleen M. Goelz and Carol J. Schwartz, Rutgers University VARIABLES

,!7IA3C1-dcahfj!:t;K;k;K;k. Addison-Wesley s JavaScript Reference Card. Kathleen M. Goelz and Carol J. Schwartz, Rutgers University VARIABLES Addison-Wesley s JavaScript Reference Card Kathleen M. Goelz and Carol J. Schwartz, Rutgers University Javascript: A scripting language designed to be integrated into HTML code to produce enhanced, dynamic,

More information

05 Case Study: C Programming Language

05 Case Study: C Programming Language CS 2SC3 and SE 2S03 Fall 2009 05 Case Study: C Programming Language William M. Farmer Department of Computing and Software McMaster University 18 November 2009 The C Programming Language Developed by Dennis

More information

Three numbers form a Pythagorean triple if the sum of squares of two numbers is equal to the square of the third.

Three numbers form a Pythagorean triple if the sum of squares of two numbers is equal to the square of the third. Pythagorean Triples Due on 2014-09-16, 23:59 IST Level: Easy Three numbers form a Pythagorean triple if the sum of squares of two numbers is equal to the square of the third. For example, 3, 5 and 4 form

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples

Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples Identifiers and Expressions CSE 130: Introduction to C Programming Spring 2005 Punctuation in C Statements are terminated with a ; Groups of statements are enclosed by curly braces: { and } Commas separate

More information

1 Problem Description

1 Problem Description CSCE2014 Programming Foundations II Lab Two (week 9-9 to 9-13) By Wing Ning Li 1 Problem Description We have introduced and studied the concept of pointer variable and learned that the name of an array

More information

Your first C program. Which one is best?

Your first C program. Which one is best? Your first C program #include void main(void) { printf( Hello, world!\n ); } #include void main(void) { printf( Hello, ); printf( world! ); printf( \n ); } Which one is best? #include

More information

What does the following code print? (Assume the program compiles without error). Trick question! Note the semicolon at the end of the second line.

What does the following code print? (Assume the program compiles without error). Trick question! Note the semicolon at the end of the second line. All multiple choice questions are equally weighted. You can generally assume that code shown in the questions is intended to be syntactically correct, unless something in the question or one of the answers

More information

Sample Problem Set #1 - SOLUTIONS

Sample Problem Set #1 - SOLUTIONS Sample Problem Set #1 - SOLUTIONS Notes: These problems are typical exam problems; most are drawn from previous homeworks and exams. This exam is open book, open notes. It may help to have a calculator.

More information

Introduction to C ++ : Questions

Introduction to C ++ : Questions Introduction to C ++ : Questions Thomas Branch 28th November 204. A Tutorial Introduction. Getting Started Aim: Make sure the program compiles and runs, learn to get the program to output text. [Debug]

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

Stacks. Linear data structures

Stacks. Linear data structures Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

More information

Standard C Input/Output. Output: printf() Table of Contents

Standard C Input/Output. Output: printf() Table of Contents Standard C Input/Output 1 Output: printf() 2 Table of Contents Output: printf( ) - syntax & sematics Output: printf( ) - examples Output: printf( ) - format control Screen / Printer Control Input: scanf(

More information

C Programming 1. C Programming

C Programming 1. C Programming C Programming 1 1 C Programming 1. Who developed the C language? Dennis M.Ritchie in 1972 2. What type of language is C? Semi-high level language 3. What is main()? The main() is a special function used

More information

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013 Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

More information

Basic Common Unix commands: Change to directory d

Basic Common Unix commands: Change to directory d Basic Common Unix commands: cd d Change to directory d mkdir d rmdir d mv f1 [f2...] d mv d1 d2 ls [d] [f...] ls -1 [f...] vi [f] emacs [f] more f cp f1 f2 mv f1 f2 rm f gcc [-o f1] f2 gnuplot Create new

More information

A TUTORIAL ON POINTERS AND ARRAYS IN C

A TUTORIAL ON POINTERS AND ARRAYS IN C A TUTORIAL ON POINTERS AND ARRAYS IN C by Ted Jensen Version 1.2 (PDF Version) Sept. 2003 This material is hereby placed in the public domain Available in various formats via http://pweb.netcom.com/~tjensen/ptr/cpoint.htm

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 4: Arrays,Strings, File I/O

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 4: Arrays,Strings, File I/O CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 4: Arrays,Strings, File I/O 2 Problem: Write a program to calculate the average test score for 10 students

More information

Birla Institute of Technology &Science, Pilani Computer Programming (CS F111) Second Semester Lab-3 (Introduction to C Programming Language)

Birla Institute of Technology &Science, Pilani Computer Programming (CS F111) Second Semester Lab-3 (Introduction to C Programming Language) Topics to be covered: 1. C Program structure and execution 2. Data type 3. Reading input and printing output 4. Expression 5. Operator precedency 6. Typecasting Birla Institute of Technology &Science,

More information

Common Errors in C. David Chisnall. February 15, 2011

Common Errors in C. David Chisnall. February 15, 2011 Common Errors in C David Chisnall February 15, 2011 The C Preprocessor Runs before parsing Allows some metaprogramming Preprocessor Macros Are Not Functions The preprocessor performs token substitution

More information

1. What is the output of this program?

1. What is the output of this program? 1. What is the output of this program? char *ptr; char string[] = "How are you?"; ptr = string; ptr += 4; printf("%s",ptr); (a) How are you? (b) are you? (c) are (d) No output 2. Which of the following

More information

Exam in EDAA25 C Programming

Exam in EDAA25 C Programming Exam in EDAA25 C Programming October 30, 2014, 14-19 Inga hjälpmedel! Examinator: Jonas Skeppstedt Grading instructions In general: assess if a function or program works as intended while ignoring syntax

More information

C Programming Language CIS 218

C Programming Language CIS 218 C Programming Language CIS 218 Description C is a procedural languages designed to provide lowlevel access to computer system resources, provide language constructs that map efficiently to machine instructions,

More information

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Programming in C: Basics CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of variable We must declare the

More information

Pointers and Strings. Objectives

Pointers and Strings. Objectives 5 Pointers and Strings Objectives To be able to use pointers. To be able to use pointers to pass arguments to functions by reference. To understand the close relationships among pointers, arrays and strings.

More information

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include

More information

Pseudocode. Pseudocode. Guide for Pseudocode. Computers in Engineering Pseudocode and C Language Review. Example Pseudocode.

Pseudocode. Pseudocode. Guide for Pseudocode. Computers in Engineering Pseudocode and C Language Review. Example Pseudocode. Computers in Engineering Pseudocode and C Language Review Pseudocode Pseudocode is an artificial and informal language that helps you develop algorithms Pseudocode is similar to everyday English; it is

More information

TN203. Porting a Program to Dynamic C. Introduction

TN203. Porting a Program to Dynamic C. Introduction TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions

More information

IMPERATIVE PROGRAMMING C LANGUAGE

IMPERATIVE PROGRAMMING C LANGUAGE J.NAWROCKI, M. ANTCZAK, H. ĆWIEK, W. FROHMBERG, A. HOFFA, M. KIERZYNKA, S. WĄSIK IMPERATIVE PROGRAMMING C LANGUAGE EX. 1. Write in C language programs described below, compile them and tentatively debug:

More information

Week 4. This is CS50. Harvard University. Fall Cheng Gong. Shellshock... 1 Breakout... 4 Merge Sort... 5 Sigma... 9 Swap GDB...

Week 4. This is CS50. Harvard University. Fall Cheng Gong. Shellshock... 1 Breakout... 4 Merge Sort... 5 Sigma... 9 Swap GDB... This is CS50. Harvard University. Fall 2014. Cheng Gong Table of Contents Shellshock... 1 Breakout... 4 Merge Sort... 5 Sigma... 9 Swap... 14 GDB... 17 Shellshock A bug has been recently discovered in

More information

Variables, types, and operators

Variables, types, and operators BUG_TRAP((int)tp->retrans_out >= 0); if (tp->packets_out==0 && tp->sack_ok) if (tp->lost_out) printk(kern_debug "Leak l=%u %d\n", tp->lost_out, tp->ca_state); tp->lost_out = 0; if (tp->sacked_out) printk(kern_debug

More information

Programming. MRS.ANURADHA BHATIA M.E. Computer Engineering MSBTE G-SCHEME

Programming. MRS.ANURADHA BHATIA M.E. Computer Engineering MSBTE G-SCHEME Software Engineering MSBTE 2. Project Scheduling G-SCHEME 2015-2016 Programming in C FIRST YEAR SUBJECT CODE 17212 COMPUTER TECHNOLOGY COMPUTER ENGINEERING INFORMATION TECHNOLOGY MRS.ANURADHA BHATIA M.E.

More information

Going from Python to C

Going from Python to C Going from Python to C Darin Brezeale December 8, 2011 Python is a high-level, interpreted language. C has many of the same types of programming constructs as in Python: arrays, loops, conditionals, functions,

More information

HOLIDAY HOMEWORK- CLASS XII COMPUTER SCIENCE Note: Attach the printout of this Home Work in Your Note book

HOLIDAY HOMEWORK- CLASS XII COMPUTER SCIENCE Note: Attach the printout of this Home Work in Your Note book HOLIDAY HOMEWORK- CLASS XII COMPUTER SCIENCE 2016-17 Note: Attach the printout of this Home Work in Your Note book 1 Write a program to calculate the sum of rows, columns of a 2D array. 2 Write a program

More information

Programming for MSc Part I

Programming for MSc Part I Herbert Martin Dietze University of Buckingham herbert@the-little-red-haired-girl.org July 24, 2001 Abstract The course introduces the C programming language and fundamental software development techniques.

More information

IC221: Systems Programming 06-Week Written Exam [SOLUTIONS]

IC221: Systems Programming 06-Week Written Exam [SOLUTIONS] IC221: Systems Programming 06-Week Written Exam [SOLUTIONS] February 12, 2014 Answer the questions in the spaces provided on the question sheets. If you run out of room for an answer, continue on the back

More information

Arrays - Introduction. Declaration of Arrays. Initialisation of Arrays. Creation of Arrays. Arrays, Strings and Collections [1]

Arrays - Introduction. Declaration of Arrays. Initialisation of Arrays. Creation of Arrays. Arrays, Strings and Collections [1] Arrays - Introduction Arrays, Strings and Collections [] Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering University of Melbourne,

More information

Bhakta Kavi Narsinh Mehta University, Junagadh

Bhakta Kavi Narsinh Mehta University, Junagadh Bhakta Kavi Narsinh Mehta University, Junagadh Draft Syllabus for B.Sc. (Computer Science) Bachelor of Science (Computer Science) (Semester - 1) Effective From June - 2016 B.Sc. (C.S.) (Semester - 1) CS-101:

More information

LAB 1 REPRESENTATION OF NUMBERS AND INTRODUCTION TO C

LAB 1 REPRESENTATION OF NUMBERS AND INTRODUCTION TO C LAB 1 REPRESENTATION OF NUMBERS AND INTRODUCTION TO C 1. LAB OBJECTIVE The objective of this lab is to review binary numbers and to review/introduce you to the C programming language and the MATLAB environment.

More information

Chapter 18 I/O in C. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Chapter 18 I/O in C. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 18 I/O in C Standard C Library I/O commands are not included as part of the C language. Instead, they are part of the Standard C Library. A collection of functions and macros that must be implemented

More information

Memoization/Dynamic Programming. The String reconstruction problem. CS125 Lecture 5 Fall 2016

Memoization/Dynamic Programming. The String reconstruction problem. CS125 Lecture 5 Fall 2016 CS125 Lecture 5 Fall 2016 Memoization/Dynamic Programming Today s lecture discusses memoization, which is a method for speeding up algorithms based on recursion, by using additional memory to remember

More information

Advanced Systems Programming

Advanced Systems Programming Advanced Systems Programming Introduction to C++ Martin Küttler September 23, 2016 1 / 21 About this presentation 2 / 21 About this presentation This presentation is not about learning to program 2 / 21

More information

An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer. University of Wyoming MA 5310 An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

More information

Programming and Data Structures

Programming and Data Structures Programming and Data Structures Tutorial sheet: 2 Topics: Decision Making, Looping and Branching Q 1. (a) What is wrong with the following loop while ( n

More information

13 Classes & Objects with Constructors/Destructors

13 Classes & Objects with Constructors/Destructors 13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.

More information