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

Similar documents
M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

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

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

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

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

Decision Making -Branching. Class Incharge: S. Sasirekha

Introduction to C Language (M3-R )

COMPUTER APPLICATION

A Fast Review of C Essentials Part I

C: How to Program. Week /Mar/05

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

Subject: Fundamental of Computer Programming 2068

Chapter 2 - Introduction to C Programming

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

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

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

Chapter 2 (Dynamic variable (i.e. pointer), Static variable)

PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam Thanjavur

BLM2031 Structured Programming. Zeyneb KURT

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

C Syntax Out: 15 September, 1995


Approximately a Test II CPSC 206

Review of the C Programming Language for Principles of Operating Systems

Basic Elements of C. Staff Incharge: S.Sasirekha

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

C Language, Token, Keywords, Constant, variable

Unit IV & V Previous Papers 1 mark Answers

DEPARTMENT OF MATHS, MJ COLLEGE

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

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

IV Unit Second Part STRUCTURES

Approximately a Final Exam CPSC 206

Data Types and Variables in C language

Arrays and Pointers (part 1)

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

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

Tokens, Expressions and Control Structures

Introduction to Computer Science Midterm 3 Fall, Points

UNIT - V STRUCTURES AND UNIONS

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

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

AMCAT Automata Coding Sample Questions And Answers

ET156 Introduction to C Programming

C Programming Review CSC 4320/6320

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

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

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5

Introduction to C Programming

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

INTRODUCTION 1 AND REVIEW

Arrays and Pointers. CSE 2031 Fall November 11, 2013

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Review of the C Programming Language

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

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

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

Arrays and Pointers (part 1)

2/28/2018. Overview. The C Programming Language Part 4. Pointers. Pointers. Pointers. Pointers

The C Programming Language Part 4. (with material from Dr. Bin Ren, William & Mary Computer Science, and

CS201- Introduction to Programming Current Quizzes

Arrays and Pointers. Arrays. Arrays: Example. Arrays: Definition and Access. Arrays Stored in Memory. Initialization. EECS 2031 Fall 2014.

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

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

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

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

A S H O R T I S H O V E R V I E W O F T H E A N S I C P R O G R A M M I N G L A N G U A G E

For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit

CSCI 171 Chapter Outlines

UNIT-V. Structures. The general syntax of structure is given below: Struct <tagname> { datatype membername1; datatype membername2; };

6.096 Introduction to C++ January (IAP) 2009

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

COP 2000 Introduction to Computer Programming Mid-Term Exam Review

Programming for Engineers Introduction to C

Creating, Compiling and Executing

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

ANSI C Reserved Words

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

Computer Organization & Systems Exam I Example Questions

Fundamental of Programming (C)

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

OBJECTIVE QUESTIONS: Choose the correct alternative:

Introduction. C provides two styles of flow control:

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)

Declaration Syntax. Declarations. Declarators. Declaration Specifiers. Declaration Examples. Declaration Examples. Declarators include:

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA

Advanced C Programming and Introduction to Data Structures

POINTER AND ARRAY SUNU WIBIRAMA

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Example of Objective Test Questions for Test 4

Homework #3 CS2255 Fall 2012

BASIC ELEMENTS OF A COMPUTER PROGRAM

C & Data Structures syllabus


There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

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

Transcription:

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 answered in the TEAR-OFF ANSWER SHEET only, attached to the question paper, as per the instructions contained therein. PART ONE is NOT to be answered in the answer book. 3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be supplied at the table when the answer sheet for PART ONE is returned. However, candidates, who complete PART ONE earlier than one hour, can collect the answer book for PART TWO immediately after handing over the answer sheet for PART ONE. TOTAL TIME: 3 HOURS TOTAL MARKS: 100 (PART ONE 40; PART TWO 60) PART ONE (Answer all the questions) 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the tear-off answer sheet attached to the question paper, following instructions therein. (1 x 10) 1.1. In a for loop with a multi statement loop body, semicolons should appear following: A) the for statement itself B) the crossing brace in the multiple statement loop body C) each statement within the loop body and the test expression D) each statement within the loop only 1.2. When we execute X++; the value of the expression X++ : A) is equal to the original value of X B) is one more than the original value of X C) is X times more than the original value of X D) none of the above 1.3. An Array s name is a: A) Pointer constant B) Pointer variable C) Variable name D) None of the above 1.4. What is printed? for ( i=1; i<=5;) i++; printf( %d,i) A) 23456 B) 12345 C) 123456 D) error A3-R3 Page 1 of 6 July, 2006

1.5. What will assign in s, when we use the following pair of statements in c-program: char *s; s = my car color is : white ; A) first character of the string constant B) complete string C) address of the string storage D) is a logical error 1.6. C uses pointers explicitly with: A) Arrays B) Structures C) Functions D) All of the above 1.7. The values of the following storage classes are initialized by the compiler A) auto and extern B) register and static C) static and extern D) auto and register 1.8. Consider the following declarations. union id char color; int size; struct char country; int date; union id i; flag; To assign a color to a flag, the correct statement would be A) flag.color = W ; B) flag.i.color = W ; C) flag.color = White ; D) flag.i.color = White ; 1.9. Which of the following is true for the switch statement: switch(var) ; A) Can be used when only one variable is tested B) The variable must be an integral type C) Each possible value of the variable can control a single branch D) All of the above 1.10. Enumeration is: A) A list of strings B) A set of numbers C) A set of legal values possible D) None of the above A3-R3 Page 2 of 6 July, 2006

2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the tear-off sheet attached to the question paper, following instructions therein. (1 x 10) 2.1 An ampersand (&) is required before each variable name in printf. 2.2 It is an error to place the pound(#) sign of a preprocessor control line in any column except column 1. 2.3 The goto statement is a branching statement in C programming. 2.4 An expression with the star operator, such as *ptr, cannot occur on the left-hand side of an assignment statement. 2.5 An array s name by itself cannot occur as the left-hand side of an assignment statement. 2.6 Function calls cannot be nested. 2.7 Each function must have at least one return statement. 2.8 A linked list is a data structure, which is created by dynamic allocation of memory. 2.9 The declaration void function-name() indicates that function-name returns nothing to the calling program. 2.10Member variables of two different structures may have the same name. 3. Match words and phrases in column X with the closest related meaning/ word(s)/phrase(s) in column Y. Enter your selection in the tear-off answer sheet attached to the question paper, following instructions therein. (1 x 10) X 3.1 a[i] can be written as A. Unending loop if no break statement inside the body 3.2 calloc( ) B. p is a pointer to a function that returns integer 3.3 union C. allocate and clear memory 3.4 for(;;) D. *(a + i) 3.5 register variable E. allocates memory but does not clear memory 3.6 int(*p)[10] F. is a memory location that is used by several different variables, which may be of different type. 3.7 int(*p)(void*,void*) G. directives 3.8 do-while loop H. Increase in speed of execution 3.9 #include, #define I. p is pointer to an array of integers 3.10 typedef J. p is function that returns pointer to integer K. This guarantees that the loop is executed at least once before continuing L. preprocessor M. can be used to create variables of new types Y A3-R3 Page 3 of 6 July, 2006

4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. Enter your choice in the tear-off answer sheet attached to the question paper, following instructions therein. (1 x 10) A. array B. string C. typedef D. Cast E. structure F. EOF G. void H. C functions I. gets J. C preprocessor K. getstr L. DEFINE M. & N. char O. malloc 4.1 The operator is used to convert one data type to another. 4.2 If the pointer variable ptr holds the address of a char, the data type of *ptr will be. 4.3 File is defined with a(n) statement. 4.4 Functions of type do not return a value to the calling segment. 4.5 A(n) is a collection of variables under a single name. 4.6 reads a whole line of input into a string until a new line or EOF is encountered. 4.7 Expressions can be made equivalent to a single identifier using the preprocessor command. 4.8 The is a program that is executed before the source code is compiled. 4.9 The operator is unary operator to find the value of a variable. 4.10Dynamic allocation of memory for structure can be done with the help of the function. A3-R3 Page 4 of 6 July, 2006

PART TWO (Answer any four questions) 5. a) Write the C Statements (all necessary statements) that open the file inf.dat for reading, and open the file outf.dat for writing. b) Write the C program to write Introduction to C-Programming to the file outf.dat. c) Write a C program that reads integers from the file scores.dat. After all the integers have been read, the program writes the sum of all the nonnegative integers to the video display. Assume that the file scores.dat contains at least one integer. (5+4+6) 6. a) Write a C program to calculate and display the monthly income of a salesperson corresponding to the value of monthly sales input in the scanf() function, let us consider the following commission schedule: (Note: use if-else statement) Monthly Sales Greater than or equal to Rs.50,000 Income 375 plus 16% of sales Less than Rs. 50,000 but Greater than or equal to Rs. 40,000 350 plus 14% of sales Less than Rs. 40,000 but Greater than or equal to Rs. 30,000 325 plus 12% of sales Less than Rs. 30,000 but Greater than or equal to Rs. 20,000 300 plus 9% of sales Less than Rs. 20,000 but Greater than or equal to Rs. 10,000 250 plus 5% of sales Less than Rs. 10,000 200 plus 3% of sales b) What is printed after execution of each of the following C-programs? 1. void main() float reals[5]; *(reals+1) = 245.8; *reals = *(reals + 1); printf( %f, reals[0] ); 2. void main( ) int nums[3]; int *ptr = nums; nums[0] = 100; nums[1] = 1000; nums[2] = 10000; printf( %d\n, ++*ptr ); printf( %d, *ptr ); A3-R3 Page 5 of 6 July, 2006

A3-R3 Page 6 of 6 July, 2006

3. void main() int digit = 0; while (digit <= 9) printf( %d\n, digit++); 4. void main() int a=7, b=6; fun1(a,b); printf( \n a is %d b is %d, a, b); int fun1(int c,int d) int e; e = c * d; d = 7 * c; printf(:\n c is %d d is %d e is %d, c, d, e); return; (7+[2x4]) 7. a) Write a C function word_count() to count the number of words in a given string and then call in Main(). b) Write a C function print_upper() to prints its character argument in uppercase. c) Write a macro that clears an array to zero. (7+4+4) 8. a) What is a Structure? Define a structure that contains the following members: i) An integer quantity called acct_no ii) A character called acct_type iii) A 40-element character array called name iv) A floating-point quantity called balance v) A structure variable called lastpayment, of type date: defined as an integer called month; an integer called day; an integer called year vi) Include the user_defined data type account within the definition. vii) Include structure variable customer, which is 100-element array of structures called account. b) What is Pointer in C? How Pointers and Arrays are related? 9. Write short notes on any three of the following: a) Switch statement (give proper syntax and examples) b) What do you mean by Loop? How while-loop and do-loop differs? c) What is C Preprocessor? Explain any two C preprocessor commands with example. d) Break and Continue Statements (8+7) (3x5) A3-R3 Page 7 of 6 July, 2006