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.

Size: px
Start display at page:

Download "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."

Transcription

1 UNIT IV 1. Appropriately comment on the following declaration int a[20]; a. Array declaration b. array initialization c. pointer array declaration d. integer array of size Appropriately comment on the following declaration int *a[20]; a. pointer initialization b. array initialization c. array of integer pointer d. array of integer pointer of size I want to store a word Pune in C strings. Which one will be the appropriate syntax? a. char city[4]={ P, u, n, e b. char city[5]={ P, u, n, e c. char city[5]={ P, u, n, e, \0 d. char city[6]={ P, u, n, e e. all the above 4. In C arrays there is only one correspondence between and values a. data types b. constants c. continuous memory d. indices 5. In arrays memory is allocated during a. runtime b. compile time c. while writing program d. none of these 6. What is the preferred size of an array for storing n elements a. n b. n+1 c. n-1 d. none of these note: I want to store 5 elements. array size will be 5, but indexing will be from 0 to 4 7. In C what is the maximum dimension of arrays? a. 1 b. 2 c. 3 d. 4 e. theoretically there is no any such limits, but practically there is limit in terms of memory 8. When array is passed as an argument to a function, what actually gets passed a. first element of array

2 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. contiguous memory locations b. random memory locations c. varies from compiler to compiler d. none of these 10. Let a be an array, which of the following operations is legal a. a++; b. ++a; c. a*5; d. a+1; 11. In which all cases specifying array size is optional a. during array initialization b. during array declaration c. at specifying formal parameters d. both a and c 12. Appropriately comment about strcmp() function a. it returns 0 if both strings are equal b. it returns 1 if both strings are equal it c. it returns -1 if both strings are equal it d. it returns nothing if both strings are equal it 13. What will be the index number of last element of an array with 50 elements? a. 50 b. 51 c. 49 d int a[100]; here I want to access 84th element, then I need to go for which case a. a[84] b. a[85] c. a[86] d. a[83] 15. In C program what will happen if we assign a value to an array element whose subscript exceeds the size of array? a. A b. A c. A d. A 16. Comment on the following statement int (*a) [10]; a. A pointer a to an array b. an array a c. an array a of pointers d. an array of characters 17. Is there any theoretical limit on maximum dimension of array

3 a. No b. Yes 18. Is there any practical limit on maximum dimension of arrays a. No b. Yes 19. In any C program a. there may or may not be any functions b. there should be at least one function c. there should be at least one function and that function should be stdio d. none of these 20. In C the default parameter passing mechanism is a. Call by Value b. Call by Reference c. call by datatype d. call by pointer 21. In C, each function can consist of a. Exactly one return statement b. only two return statements c. only 3 return statements d. zero or any number of return statements 22. In C program, a return statement in any function may return a. only one value to calling function b. only two values to calling function c. only three values to calling function d. many values to calling function 23. In C the recursive function are executed in which fashion a. first in first out (FIFO) b. last in first out (LIFO) c. concurrent fashion d. in any fashion 24. The scope of local variable is a. from the point of declaration to the end of the function where they are declared b. only in main function and not in any other functions c. only in user defined functions and not in main function d. only in user defined function and standard library functions and not in mail function 25. The scope of global variable is a. from the point of declaration down to the end of file b. only in main function and not in any other functions

4 c. only in user defined functions and not in main function d. only in user defined function and standard library functions and not in mail function 26. Variables declared within a pair of braces in any loops are called as a. local variables b. Global variable c. very local variables d. none of these 27. The scope of very local variables is a. from the point of declaration to the end of the block in which they are declared b. only in main function and not in any other functions c. only in user defined functions and not in main function d. only in user defined function and standard library functions and not in mail function 28. If a particular function is not returning anything then the suitable return type of such function is a. int b. double c. float d. char e. void 29. In Call by Value all changes made to variables are a. local b. global c. semi global d. none of these 30. which is the correct Syntax of function declaration in C a. return_type function_name (arguments type) b. return_type function_name (arguments type); c. return_type function_name () d. return_type arguments type function_name (); 31. Which of the following is valid function declaration in C? a. int add(int,int); b. int add(a,b); c. int add(int,int) d. int add(int *, int *); e. both a and d 32. Which of the following is correct Syntax of function call a. function_name(list of arguments); b. function_name(types of arguments ); c. function_name(return type); d. none of these 33. The arguments used during function call are called

5 a. actual arguments b. global arguments c. formal arguments d. none of these 34. The arguments used during function definition are called a. actual arguments b. global arguments c. formal arguments d. none of these 35. In C what is the return type of inbuilt function sqrt()? a. float b. void c. int d. double 36. Which are faster? recursive functions or loops? a. loops b. recursive functions c. both are same d. none of these 37. In C, I want to print \n as output, this can be done using which of the following statement a. printf( \n ); b. printf( \n\n ); c. printf( \\n ); d. printf( \n\ ); 38. In C, I want to read multiword string. This can be achieved using which of the following inbuilt function a. scanf(); b. read(); c. readmultiple(); d. gets(); 39. In C strings the return type used is/are a. void b. int c. char * d. all the above 40. In C, the strings always ends with a. return character b. end character c. null character d. none of these 41. In C after reading the strings from user through keyboard, the null character is to be a. inserted by programmers b. inserted by user c. automatically inserted by compiler d. none of these 42. Array index always starts with a. 0 b. 1 c. n d. n In C which of the following is invalid function declaration a. int add(int,int); b. float add(float,float); c. float add(int,int); d. float add(float,int); e. int add(int,float); 44. In C string each character in an array occupies how many bytes of memory a. 1 b. 2 c. 4 d. 8

6 45. For strings standard operators for assignment and comparison are available. Is it true or false? a. true b. false 46. For strings standard operators for assignment and comparison are not available. The reason is a. Strings are array of characters b. Arrays also don t have standard operators for assignment and comparison c. Both a and c d. None of these 47. Which of the following is not used in Call by Value a. arrays b. strings c. integers d. chars e. both a and b 48. Command line arguments are those that a. they take input from user before running b. input is provided in the program itself c. input is provided from external files d. all the above 49. Which of the following function is called first Value=add(3,6) + sub(4,5) * mul(5,6); a. add() b. sub() c. mul() d. unable to predict, depends on compiler int a[2]={10,20; printf("%d\t%d",0[a],1[a]); int a[3]={10,20,30; printf("%u %u %u %u\n",&a,&a[0],&a[1],&a[2]);

7 int a[2][2]={10,20,30,40; printf("%d ",&a[1][1]); printf("%d ",&a[0][0]); printf("%d ",&a[1][1] - &a[0][0]); int a[2]={10,20; printf("%d %d",a[-2],a[100]); int a[4]={10,20,30,40; printf("%u ",&a); printf("%u ",&a+1); printf("%u ",a+1); int add(int,int); int a,b,c; printf("enter Values of a and b\n"); scanf("%d%d",&a,&b); c=add(a,b); printf("addition is: %d\n",c); main(); int add(int g, int h)

8 { int i; i=g+h; return i; int a,b,c; scanf("%d%d",&a,&b); c=a+b; printf("addition is: %d\n",c); main(); int add (void) { int a,b,c; printf("enter Values of a and b\n"); scanf("%d%d",&a,&b); c=a+b; printf("addition is: %d\n",c); void display(); int main (void) { printf("a"); display(); printf("c"); void display(); void display() { printf("b");

9 printf("%d",printf("hello\n")); Answer Key 1 D 25 A 49 D D 26 C C 27 A D 28 E B 29 A A 30 B E 31 E E 32 A A 33 A D 34 C D 35 D A 36 A C 37 C D 38 D D A 40 C A 41 C B 42 A B 43 E A 44 A D 45 B A 46 C B 47 E A 48 A

10

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: 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

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

UNIT III (PART-II) & UNIT IV(PART-I)

UNIT III (PART-II) & UNIT IV(PART-I) UNIT III (PART-II) & UNIT IV(PART-I) Function: it is defined as self contained block of code to perform a task. Functions can be categorized to system-defined functions and user-defined functions. System

More information

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

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

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

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3 Programming in C main Level 2 Level 2 Level 2 Level 3 Level 3 1 Programmer-Defined Functions Modularize with building blocks of programs Divide and Conquer Construct a program from smaller pieces or components

More information

DECLARAING AND INITIALIZING POINTERS

DECLARAING AND INITIALIZING POINTERS DECLARAING AND INITIALIZING POINTERS Passing arguments Call by Address Introduction to Pointers Within the computer s memory, every stored data item occupies one or more contiguous memory cells (i.e.,

More information

Functions. (transfer of parameters, returned values, recursion, function pointers).

Functions. (transfer of parameters, returned values, recursion, function pointers). Functions (transfer of parameters, returned values, recursion, function pointers). A function is a named, independent section of C/C++ code that performs a specific task and optionally returns a value

More information

Pointers. Pointers. Pointers (cont) CS 217

Pointers. Pointers. Pointers (cont) CS 217 Pointers CS 217 Pointers Variables whose values are the addresses of variables Operations address of (reference) & indirection (dereference) * arithmetic +, - Declaration mimics use char *p; *p is a char,

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

Unit 7. Functions. Need of User Defined Functions

Unit 7. Functions. Need of User Defined Functions Unit 7 Functions Functions are the building blocks where every program activity occurs. They are self contained program segments that carry out some specific, well defined task. Every C program must have

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

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

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 EECE.2160: ECE Application Programming Spring 2016 Exam 1 February 19, 2016 Name: Section (circle 1): 201 (8-8:50, P. Li) 202 (12-12:50, M. Geiger) For this exam, you may use only one 8.5 x 11 double-sided

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

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

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

Q 1. Attempt any TEN of the following:

Q 1. Attempt any TEN of the following: Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The

More information

Fundamentals of Programming Session 14

Fundamentals of Programming Session 14 Fundamentals of Programming Session 14 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines

More information

It is necessary to have a single function main in every C program, along with other functions used/defined by the programmer.

It is necessary to have a single function main in every C program, along with other functions used/defined by the programmer. Functions A number of statements grouped into a single logical unit are called a function. The use of function makes programming easier since repeated statements can be grouped into functions. Splitting

More information

Array Initialization

Array Initialization Array Initialization Array declarations can specify initializations for the elements of the array: int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ; initializes primes[0] to 2, primes[1] to 3, primes[2]

More information

UNDERSTANDING THE COMPUTER S MEMORY

UNDERSTANDING THE COMPUTER S MEMORY POINTERS UNDERSTANDING THE COMPUTER S MEMORY Every computer has a primary memory. All our data and programs need to be placed in the primary memory for execution. The primary memory or RAM (Random Access

More information

Approximately a Final Exam CPSC 206

Approximately a Final Exam CPSC 206 Approximately a Final Exam CPSC 206 Sometime in History based on Kelley & Pohl Last name, First Name Last 4 digits of ID Write your section number: All parts of this exam are required unless plainly and

More information

Pointers. Pointer References

Pointers. Pointer References Pointers Pointers are variables whose values are the addresses of other variables Basic operations address of (reference) indirection (dereference) Suppose x and y are integers, p is a pointer to an integer:

More information

3/22/2016. Pointer Basics. What is a pointer? C Language III. CMSC 313 Sections 01, 02. pointer = memory address + type

3/22/2016. Pointer Basics. What is a pointer? C Language III. CMSC 313 Sections 01, 02. pointer = memory address + type Pointer Basics What is a pointer? pointer = memory address + type C Language III CMSC 313 Sections 01, 02 A pointer can contain the memory address of any variable type A primitive (int, char, float) An

More information

10/20/2015. Midterm Topic Review. Pointer Basics. C Language III. CMSC 313 Sections 01, 02. Adapted from Richard Chang, CMSC 313 Spring 2013

10/20/2015. Midterm Topic Review. Pointer Basics. C Language III. CMSC 313 Sections 01, 02. Adapted from Richard Chang, CMSC 313 Spring 2013 Midterm Topic Review Pointer Basics C Language III CMSC 313 Sections 01, 02 1 What is a pointer? Why Pointers? Pointer Caution pointer = memory address + type A pointer can contain the memory address of

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

Bil 104 Intiroduction To Scientific And Engineering Computing. Lecture 7

Bil 104 Intiroduction To Scientific And Engineering Computing. Lecture 7 Strings and Clases BIL104E: Introduction to Scientific and Engineering Computing Lecture 7 Manipulating Strings Scope and Storage Classes in C Strings Declaring a string The length of a string Copying

More information

Single Dimension Arrays

Single Dimension Arrays ARRAYS Single Dimension Arrays Array Notion of an array Homogeneous collection of variables of same type. Group of consecutive memory locations. Linear and indexed data structure. To refer to an element,

More information

Arrays Arrays and pointers Loops and performance Array comparison Strings. John Edgar 2

Arrays Arrays and pointers Loops and performance Array comparison Strings. John Edgar 2 CMPT 125 Arrays Arrays and pointers Loops and performance Array comparison Strings John Edgar 2 Python a sequence of data access elements with [index] index from [0] to [len-1] dynamic length heterogeneous

More information

EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution

EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Advanced C Programming and Introduction to Data Structures

Advanced C Programming and Introduction to Data Structures FYBCA Semester II (Advanced C Programming and Introduction to Data Structures) Question Bank Multiple Choice Questions Unit-1 1. Which operator is used with a pointer to access the value of the variable

More information

Example: Structure, Union. Syntax. of Structure: struct book { char title[100]; char author[50] ]; float price; }; void main( )

Example: Structure, Union. Syntax. of Structure: struct book { char title[100]; char author[50] ]; float price; }; void main( ) Computer Programming and Utilization ( CPU) 110003 Structure, Union 1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different

More information

Variation of Pointers

Variation of Pointers Variation of Pointers A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before

More information

ARRAYS(II Unit Part II)

ARRAYS(II Unit Part II) ARRAYS(II Unit Part II) Array: An array is a collection of two or more adjacent cells of similar type. Each cell in an array is called as array element. Each array should be identified with a meaningful

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

ESC101N Fundamentals of Computing

ESC101N Fundamentals of Computing ESC101N Fundamentals of Computing Arnab Bhattacharya arnabb@iitk.ac.in Indian Institute of Technology, Kanpur http://www.iitk.ac.in/esc101/ 1 st semester, 2010-11 Tue, Wed, Fri 0800-0900 at L7 Arnab Bhattacharya

More information

Functions BCA-105. Few Facts About Functions:

Functions BCA-105. Few Facts About Functions: Functions When programs become too large and complex and as a result the task of debugging, testing, and maintaining becomes difficult then C provides a most striking feature known as user defined function

More information

OBJECTIVE QUESTIONS: Choose the correct alternative:

OBJECTIVE QUESTIONS: Choose the correct alternative: OBJECTIVE QUESTIONS: Choose the correct alternative: 1. Function is data type a) Primary b) user defined c) derived d) none 2. The declaration of function is called a) function prototype b) function call

More information

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017 Section 1: Multiple choice (select any that apply) - 20 points 01. Representing 10 using the 4 byte unsigned integer encoding and using 4 byte two s complements encoding yields the same bit pattern. (a)

More information

IV Unit Second Part STRUCTURES

IV Unit Second Part STRUCTURES STRUCTURES IV Unit Second Part Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure

More information

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

First of all, it is a variable, just like other variables you studied Pointers: Basics What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the address (rather than the value)

More information

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays A First Book of ANSI C Fourth Edition Chapter 8 Arrays Objectives One-Dimensional Arrays Array Initialization Arrays as Function Arguments Case Study: Computing Averages and Standard Deviations Two-Dimensional

More information

Homework #3 CS2255 Fall 2012

Homework #3 CS2255 Fall 2012 Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation

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

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

Memory Allocation in C

Memory Allocation in C Memory Allocation in C When a C program is loaded into memory, it is organized into three areas of memory, called segments: the text segment, stack segment and heap segment. The text segment (also called

More information

C Introduction. Comparison w/ Java, Memory Model, and Pointers

C Introduction. Comparison w/ Java, Memory Model, and Pointers CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language

More information

Introduction to C Final Review Chapters 1-6 & 13

Introduction to C Final Review Chapters 1-6 & 13 Introduction to C Final Review Chapters 1-6 & 13 Variables (Lecture Notes 2) Identifiers You must always define an identifier for a variable Declare and define variables before they are called in an expression

More information

UNIT 2 ARRAYS 2.0 INTRODUCTION. Structure. Page Nos.

UNIT 2 ARRAYS 2.0 INTRODUCTION. Structure. Page Nos. UNIT 2 ARRAYS Arrays Structure Page Nos. 2.0 Introduction 23 2.1 Objectives 24 2.2 Arrays and Pointers 24 2.3 Sparse Matrices 25 2.4 Polynomials 28 2.5 Representation of Arrays 30 2.5.1 Row Major Representation

More information

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 16.216: ECE Application Programming Spring 2015 Exam 1 February 23, 2015 Name: ID #: For this exam, you may use only one 8.5 x 11 double-sided page of notes. All electronic devices (e.g., calculators,

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

Introduction to C Language (M3-R )

Introduction to C Language (M3-R ) Introduction to C Language (M3-R4-01-18) 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in OMR answer sheet supplied with the question paper, following

More information

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

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2015) ramana@cs.columbia.edu Lecture-2 Overview of C continued C character arrays Functions Structures Pointers C++ string class C++ Design, difference with C

More information

Solutions to Assessment

Solutions to Assessment Solutions to Assessment 1. In the bad character rule, what are the values of R(P) for the given pattern. CLICKINLINK (Please refer the lecture). Ans: a) C-1,K-10,N-9,I-8,L-2 b) C-1,K-10,N-9,I-8,L-7 c)

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY Objectives Declaration of 1-D and 2-D Arrays Initialization of arrays Inputting array elements Accessing array elements Manipulation

More information

UNIT - V STRUCTURES AND UNIONS

UNIT - V STRUCTURES AND UNIONS UNIT - V STRUCTURES AND UNIONS STRUCTURE DEFINITION A structure definition creates a format that may be used to declare structure variables. Let us use an example to illustrate the process of structure

More information

Functions in C. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 16 March 9, 2011

Functions in C. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 16 March 9, 2011 Functions in C Lecture Topics Introduction to using functions in C Syntax Examples Memory allocation for variables Lecture materials Textbook 14.1-14.2, 12.5 Homework Machine problem MP3.2 due March 18,

More information

To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows

To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows Unti 4: C Arrays Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type An array is used to store a collection of data, but it is often more useful

More information

Topics so far. Review. scanf/fscanf. How data is read 1/20/2011. All code handin sare at /afs/andrew/course/15/123/handin

Topics so far. Review. scanf/fscanf. How data is read 1/20/2011. All code handin sare at /afs/andrew/course/15/123/handin 15-123 Effective Programming in C and Unix Announcements SL2 is due Thursday 1/20 midnight Complete the Academic Honesty Form in class All code downloads are from /afs/andrew/course/15/123/download All

More information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 13, SPRING 2013

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 13, SPRING 2013 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 13, SPRING 2013 TOPICS TODAY Reminder: MIDTERM EXAM on THURSDAY Pointer Basics Pointers & Arrays Pointers & Strings Pointers & Structs

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

The role of semantic analysis in a compiler

The role of semantic analysis in a compiler Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE

A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE A3-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

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

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their

More information

CSE 2421: Systems I Low-Level Programming and Computer Organization. Functions. Presentation C. Predefined Functions

CSE 2421: Systems I Low-Level Programming and Computer Organization. Functions. Presentation C. Predefined Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Functions Read/Study: Reek Chapters 7 Gojko Babić 01-22-2018 Predefined Functions C comes with libraries of predefined functions E.g.:

More information

Computers Programming Course 10. Iulian Năstac

Computers Programming Course 10. Iulian Năstac Computers Programming Course 10 Iulian Năstac Recap from previous course 5. Values returned by a function A return statement causes execution to leave the current subroutine and resume at the point in

More information

COMP26120: Linked List in C (2018/19) Lucas Cordeiro

COMP26120: Linked List in C (2018/19) Lucas Cordeiro COMP26120: Linked List in C (2018/19) Lucas Cordeiro lucas.cordeiro@manchester.ac.uk Linked List Lucas Cordeiro (Formal Methods Group) lucas.cordeiro@manchester.ac.uk Office: 2.28 Office hours: 10-11 Tuesday,

More information

Two Dimensional Arrays

Two Dimensional Arrays 2-d Arrays 1 Two Dimensional Arrays We have seen that an array variable can store a list of values Many applications require us to store a table of values Student 1 Student 2 Student 3 Student 4 Subject

More information

Part II Answer to all the questions (2 Marks):

Part II Answer to all the questions (2 Marks): Unit - III CHAPTER - 11 Functions in C++ Part 1 Choose the best answer 1. Which of the following header file defines the standard I/O predefined functions? A) stdio.h B) math.h C) string.h D) ctype.h 2.

More information

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point

More information

Arrays and Pointers (part 1)

Arrays and Pointers (part 1) Arrays and Pointers (part 1) CSE 2031 Fall 2012 Arrays Grouping of data of the same type. Loops commonly used for manipulation. Programmers set array sizes explicitly. Arrays: Example Syntax type name[size];

More information

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. If a function has default arguments, they can be located anywhere

More information

Unit IV & V Previous Papers 1 mark Answers

Unit IV & V Previous Papers 1 mark Answers 1 What is pointer to structure? Pointer to structure: Unit IV & V Previous Papers 1 mark Answers The beginning address of a structure can be accessed through the use of the address (&) operator If a variable

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence

More information

CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011

CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011 CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011 Date: 01/18/2011 (Due date: 01/20/2011) Name and ID (print): CHAPTER 6 USER-DEFINED FUNCTIONS I 1. The C++ function pow has parameters.

More information

Multiple Choice Questions ( 1 mark)

Multiple Choice Questions ( 1 mark) Multiple Choice Questions ( 1 mark) Unit-1 1. is a step by step approach to solve any problem.. a) Process b) Programming Language c) Algorithm d) Compiler 2. The process of walking through a program s

More information

Lab 3. Pointers Programming Lab (Using C) XU Silei

Lab 3. Pointers Programming Lab (Using C) XU Silei Lab 3. Pointers Programming Lab (Using C) XU Silei slxu@cse.cuhk.edu.hk Outline What is Pointer Memory Address & Pointers How to use Pointers Pointers Assignments Call-by-Value & Call-by-Address Functions

More information

Pointers. 1 Background. 1.1 Variables and Memory. 1.2 Motivating Pointers Massachusetts Institute of Technology

Pointers. 1 Background. 1.1 Variables and Memory. 1.2 Motivating Pointers Massachusetts Institute of Technology Introduction to C++ Massachusetts Institute of Technology ocw.mit.edu 6.096 Pointers 1 Background 1.1 Variables and Memory When you declare a variable, the computer associates the variable name with a

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

CSE 230 Intermediate Programming in C and C++ Functions

CSE 230 Intermediate Programming in C and C++ Functions CSE 230 Intermediate Programming in C and C++ Functions Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse230/ Concept of Functions

More information

Lecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions

Lecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions Lecture 02 Summary C/Java Syntax Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 1 2 By the end of this lecture, you will be able to identify the

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

User Defined Functions

User Defined Functions User Defined Functions CS 141 Lecture 4 Chapter 5 By Ziad Kobti 27/01/2003 (c) 2003 by Ziad Kobti 1 Outline Functions in C: Definition Function Prototype (signature) Function Definition (body/implementation)

More information

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock) C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 By the end of this lecture, you will be able to identify the

More information

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 1 By the end of this lecture, you will be able to identify

More information

Lecture 3: C Programm

Lecture 3: C Programm 0 3 E CS 1 Lecture 3: C Programm ing Reading Quiz Note the intimidating red border! 2 A variable is: A. an area in memory that is reserved at run time to hold a value of particular type B. an area in memory

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5 1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different data types grouped together under a single name. Structure is

More information

EC 413 Computer Organization

EC 413 Computer Organization EC 413 Computer Organization C/C++ Language Review Prof. Michel A. Kinsy Programming Languages There are many programming languages available: Pascal, C, C++, Java, Ada, Perl and Python All of these languages

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

{C} Programming. Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics

{C} Programming. Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics {C Programming Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics Variables A variable is a container (storage area) to hold data. Eg. Variable name int potionstrength = 95; Variable

More information

Write a C program using arrays and structure

Write a C program using arrays and structure 03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string

More information