MCA Semester 1. MC0061 Computer Programming C Language 4 Credits Assignment: Set 1 (40 Marks)
|
|
- Allan Cunningham
- 6 years ago
- Views:
Transcription
1 Summer 2012 MCA Semester 1 4 Credits Assignment: Set 1 (40 Marks) Q1. Explain the following operators with an example for each: a. Conditional Operators b. Bitwise Operators c. gets() and puts() function with a programming example for each. Answer: a. Conditional Operators The Conditional operator is also called as Ternary Operator. The conditional operator consists of 2 symbols the question mark (?) and the colon (:). The syntax for a ternary operator is as follows exp1? exp2 : exp3 The conditional operator works as follows exp1 is evaluated first. If the expression is true then exp2 is evaluated & its value becomes the value of the expression. If exp1 is false, exp3 is evaluated and its value becomes the value of the expression. Note that only one of the expression is evaluated. Example a = 10; b = 15; x = (a > b)? a : b Here x will be assigned to the value of b. The condition follows that the expression is false therefore b is assigned to x. b. Bitwise Operators C has a distinction of supporting special operators known as bitwise operators for manipulation DATA at bit level. A bitwise operator operates on each bit of DATA. Those operators are used for testing, complementing or shifting bits to the right on left. Bitwise operators may not be applied to a float or double.
2 Operator & Meaning Bitwise AND Bitwise OR ^ Bitwise Exclusive Example, << Shift left >> Shift right The & operator performs a bitwise AND on two integers. Each bit in the result is 1 only if both corresponding bits in the two input operands are 1. x= y & z; assigns x the result of "y AND z". This is different from logical "and" operator, "&&", which takes two logical operands as input and produces a result of "true" or "false". If, y = 0x56 z = 0x32 Then, x will be 0x12, because (in binary) & c. gets() and puts() function gets() reads a complete line of text into a string until a end-of-file (EOF) is encountered. It is the responsibility of the programmer to ensure that the string which receives the input text read by gets is large enough. puts() displays a string onto the standard output or terminal and follows it with a newlinecharacter. #include <stdio.h> main () char answer[256]; puts("enter your name");
3 while((gets(answer))!= NULL) printf("hello " %s, answer);
4 Q2. Explain the following with a programming example for each: a. Arrays of Structures b. Unions Answer: a. Arrays of Structures We can use structures to describe the format of a number of related variables. For example, in analyzing the marks obtained by a class of students, we may use a template to describe student name and marks obtained in various subjects and then declare all the students as structure variables. In such cases, we may declare an array of structures, each element of the array representing a structure variable. e.g, struct stclass student[100]; defines an array called student, that consists of 100 elements. Each element is defined to be of the type struct stclass. Consider the following declaration : struct marks int subject1; int subject2; int subject3; ; main( ) static struct marks student[3]=45,68,81,75,53,69,57,36,71; This declares the student as an array of three elements student[0], student[1] and student[2] and initializes their members as follows: student[0].subject1 = 45; student[0].subject2 = 68;.. student[2].subject3 = 71;
5 Example: Program to process employee details using structures #include<conio.h> #include<stdio.h> struct employee int empno; char name[30]; int basic; int hra; ; void main() int i,j,n,net[50]; float avg; employee e[50]; printf( \nenter the number of employees: ); scanf( %d, &n); printf( \nenter Empno.\tName\tBasic\tHra of each employee:\n ); for(i=0;i<n;i++) scanf( %d,&e[i].empno); gets(e[i].name); scanf( %d,&e[i].basic); scanf(%d,&e[i].hra);
6 net[i]= e[i].basic+e[i].hra; avg=avg+net[i]; avg=avg/n; printf( \nempno.\tname\tnetpay\n ); for(i=0;i<n;i++) if(net[i]>avg) printf(e[i].empno\t) ; printf(e[i].name\t) ; printf(net[i]\n ); getch(); b. Unions Unions look similar to structures. They have identical declaration syntax and member access, but they serve a very different purpose. union Utype int ival; float fval; char *sval;
7 ; union Utype x, y, z; Accessing members of a union is via. member operator or, for pointers to unions, the -> operator. A union holds the value of one-variable at a time. The compiler allocates storage for the biggest member of the union. The type retrieved from the union must be the type most recently stored. Otherwise, the result is implementation dependent. union Utype x; x.fval = 56.4; /* x holds type float. */ printf( %f\n, x.fval); /* OK. */ printf( %d\n, x.ival); /* Implementation dependent. */ Unions are used to store one of a set of different types. These are commonly used to implement a variant array. (This is a form of generic programming.) There are other uses also, but they are quite advanced (e.g., concern the alignment properties of unions). Example: #include <stdio.h> #include <conio.h> Void main () Union Int I; Float f; Double d; u; Printf ( %d, sizeof (u)); u.i = 100; Printf ( %d%f%f, u.i, u.f, u.d); u.f = 0.5; Printf ( %d%f%f, u.i, u.f, u.d); u.d = ; Printf ( %d%f%f, u.i, u.f, u.d);
8 Q3. Write a program demonstrating the usage of pointers with one dimensional and two dimensional arrays. Answer: Arrays and pointers are very intimately connected. Most important point to remember is that array name without the brackets is the base address of that array or address of its first (0th) element. This address can be stored in the pointer. More fading this subtle difference is that pointer can also be used with brackets to index array as if it was an array name. In general access provided by the pointer is faster if pointer arithmetic(which by the way is almost completely different from normal arithmetic)is used for acess. Formula for accessing I th element in a 1-D array is - *(pointer name + I) Formula for accessing I th row, J th Column element in a 2-D array is - *(pointer name + I * Number_Of_Elements_Per_Row + J) And so on, formula become more complicated with increase in dimension of the array. Code below shows how to access a 1-D array using pointers. #include <stdio.h> int main () int value [1000],i; // Declaring an Array int *pointer; pointer = value; for (i = 0; i<1000; i++) *(pointer +i) = i; // Loading the Array for (i = 0; i<1000; i++) printf ("\n%d",*(pointer + i); // Displaying the Array return 0; An array is actually very much like pointer. We can declare the arrays first element as a[0] or asint *a because a[0] is an address and *a is also an address the form of declaration is equivalent. The difference is pointer is a avalchanda and can appear on the left of the
9 assignment operator that is lvalue. The array name is constant and cannot appear as the left side of assignment operator. An example program which shows how to access 2-D array using pointer : #include <stdio.h> #include <stdlib.h> main() long mat[5][5], **ptr; mat[0][0] = 3; ptr = (long **)mat; printf(" mat %p \n", mat); printf(" ptr %p \n", ptr); printf(" mat[0][0] %d \n", mat[0][0]); printf(" &mat[0][0] %p \n", &mat[0][0]); printf(" &ptr[0][0] %p \n", &ptr[0][0]); return; The output is: mat 7FDF6310ptr 7FDF6310mat[0][0] 3&mat[0][0] 7FDF6310&ptr[0][0] 3
10 Q4. Describe the following with suitable programming examples: a. Input/Output operations on files b. Predefined Streams c. Error handling during I/O operations d. Random access to files Remaining answers are available in the full assignments. For full assignments contact us: Global Education Rajdeep: / support@smuassignments.com / global.education_smu@yahoo.in Website: Note: The diagonally marked watermark (Sample Assignment of smuassignments.com) will not appear in the paid assignments.
M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE
M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationComputers Programming Course 6. Iulian Năstac
Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap
More informationIV 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 informationSubject: Fundamental of Computer Programming 2068
Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find
More informationA flow chart is a graphical or symbolic representation of a process.
Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of
More informationOperators in C. Staff Incharge: S.Sasirekha
Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C
More informationUNIT - 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 informationComputers Programming Course 5. Iulian Năstac
Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction
More informationObject Oriented Pragramming (22316)
Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data
More informationDynamic Memory Allocation
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility, there are four library routines known as memory management
More informationComputer 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 informationF.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C
F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.
More information3.3 Structures. Department of CSE
3.3 Structures 1 Department of CSE Objectives To give an introduction to Structures To clearly distinguish between Structures from Arrays To explain the scenarios which require Structures To illustrate
More informationESC101N: 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 informationBit Manipulation in C
Bit Manipulation in C Bit Manipulation in C C provides six bitwise operators for bit manipulation. These operators act on integral operands (char, short, int and long) represented as a string of binary
More informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
More informationPrepared by: Shraddha Modi
Prepared by: Shraddha Modi Introduction Operator: An operator is a symbol that tells the Computer to perform certain mathematical or logical manipulations. Expression: An expression is a sequence of operands
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationC library = Header files + Reserved words + main method
DAY 1: What are Libraries and Header files in C. Suppose you need to see an Atlas of a country in your college. What do you need to do? You will first go to the Library of your college and then to the
More informationQ 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 informationAbout Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals
More informationLaboratory 3 OPERATORS, EXPRESSIONS, INSTRUCTIONS I. THEORETICAL BACKGROUND
PROGRAMMING LANGUAGES Laboratory 3 OPERATORS, EXPRESSIONS, INSTRUCTIONS I. THEORETICAL BACKGROUND 1. Operators and expressions An expression combines variables and constants in order to produce new values.
More informationOutline. Computer Memory Structure Addressing Concept Introduction to Pointer Pointer Manipulation Summary
Pointers 1 2 Outline Computer Memory Structure Addressing Concept Introduction to Pointer Pointer Manipulation Summary 3 Computer Memory Revisited Computers store data in memory slots Each slot has an
More informationArray. Arrays. Declaring Arrays. Using Arrays
Arrays CS215 Peter Lo 2004 1 Array Array Group of consecutive memory locations Same name and type To refer to an element, specify Array name Position number Format: arrayname[ position number] First element
More informationSample Examination. Family Name:... Other Names:... Signature:... Student Number:...
Family Name:... Other Names:... Signature:... Student Number:... THE UNIVERSITY OF NEW SOUTH WALES SCHOOL OF COMPUTER SCIENCE AND ENGINEERING Sample Examination COMP1917 Computing 1 EXAM DURATION: 2 HOURS
More informationUNIT - I. Introduction to C Programming. BY A. Vijay Bharath
UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been
More informationProgramming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme]
Programming in C and Data Structures [15PCD13/23] 1 PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme] Course objectives: The objectives of this course is to make students
More informationPointers and Arrays 1
Pointers and Arrays 1 Pointers and Arrays When an array is declared, The compiler allocates sufficient amount of storage to contain all the elements of the array in contiguous memory locations The base
More informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
More informationOBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object
More informationHigh Performance Computing in C and C++
High Performance Computing in C and C++ Rita Borgo Computer Science Department, Swansea University Summary Introduction to C Writing a simple C program Compiling a simple C program Running a simple C program
More informationCOMPUTER APPLICATION
Total No. of Printed Pages 16 HS/XII/A.Sc.Com/CAP/14 2 0 1 4 COMPUTER APPLICATION ( Science / Arts / Commerce ) ( Theory ) Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks for
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationCS6202 - 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 informationGuide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:
Q1. Explain the structure of a C program Structure of the C program is shown below: Preprocessor Directives Global Declarations Int main (void) Local Declarations Statements Other functions as required
More informationWriting an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and
Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()
More informationC BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.
C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,
More informationLecture 02 C FUNDAMENTALS
Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationType Checking. Prof. James L. Frankel Harvard University
Type Checking Prof. James L. Frankel Harvard University Version of 7:10 PM 27-Feb-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. C Types C Types Type Category Type Category Type
More informationLab 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 informationCS201- 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 informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. DECLARING POINTERS POINTERS A pointer represents both
More informationUNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING
( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationC Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008
C Programming Language: C ADTs, 2d Dynamic Allocation Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008 Overview Row major format 1 and 2-d dynamic allocation struct
More informationI Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.
I Internal Examination Sept. 2018 Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. [I]Very short answer questions (Max 40 words). (5 * 2 = 10) 1. What is
More informationBasic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types
More informationExpressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators
Expressions 1 Expressions n Variables and constants linked with operators Arithmetic expressions n Uses arithmetic operators n Can evaluate to any value Logical expressions n Uses relational and logical
More informationIntroduction. Structures, Unions, Bit Manipulations, and Enumerations. Structure. Structure Definitions
Introduction Structures, Unions, Bit Manipulations, and Enumerations In C, we can create our own data types If programmers do a good job of this, the end user does not even have to know what is in the
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationLecture 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 informationM3-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 informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationChapter 2 (Dynamic variable (i.e. pointer), Static variable)
Chapter 2 (Dynamic variable (i.e. pointer), Static variable) August_04 A2. Identify and explain the error in the program below. [4] #include int *pptr; void fun1() { int num; num=25; pptr= #
More informationC/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 informationC/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 informationPresented By : Gaurav Juneja
Presented By : Gaurav Juneja Introduction C is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs of UNIX are written
More informationSolutions 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 informationComputers Programming Course 7. Iulian Năstac
Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
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 model answer and the answer written by candidate
More informationB.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 informationOperators and Type Conversion. By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE
Operators and Type Conversion By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE Introduction An operator is a symbol which represents a particular operation that can be performed on some data.
More informationA complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.
1.3a Expressions Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a syntactical token that requires an action be taken An operand is an object
More informationDynamic memory allocation
Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes
More informationIntroduction to C An overview of the programming language C, syntax, data types and input/output
Introduction to C An overview of the programming language C, syntax, data types and input/output Teil I. a first C program TU Bergakademie Freiberg INMO M. Brändel 2018-10-23 1 PROGRAMMING LANGUAGE C is
More informationC Programming Multiple. Choice
C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980
More informationUnit 3 Decision making, Looping and Arrays
Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.
More informationDownloaded S. from Kiran, PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from
Downloaded S. from Kiran, www.studiestoday.com PGT (CS) KV, STRUCTURES WHAT IS A STRUCTURE? Structure is a collection of logically related data. It is also a collection of dissimilar datatype. Downloaded
More informationSelf-referential Structures and Linked List. Programming and Data Structure 1
Self-referential Structures and Linked List Programming and Data Structure 1 Linked List :: Basic Concepts A list refers to a set of items organized sequentially. An array is an example of a list. The
More informationLanguage comparison. C has pointers. Java has references. C++ has pointers and references
Pointers CSE 2451 Language comparison C has pointers Java has references C++ has pointers and references Pointers Values of variables are stored in memory, at a particular location A location is identified
More informationMulti-Dimensional arrays
Multi-Dimensional arrays An array having more then one dimension is known as multi dimensional arrays. Two dimensional array is also an example of multi dimensional array. One can specify as many dimensions
More informationSAE1A Programming in C. Unit : I - V
SAE1A Programming in C Unit : I - V Unit I - Overview Character set Identifier Keywords Data Types Variables Constants Operators SAE1A - Programming in C 2 Character set of C Character set is a set of
More informationNote: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be.
CS 156 : COMPUTER SYSTEM CONCEPTS TEST 1 (C PROGRAMMING PART) FEBRUARY 6, 2001 Student s Name: MAXIMUM MARK: 100 Time allowed: 45 minutes Note: unless otherwise stated, the questions are with reference
More informationArrays, Pointers and Memory Management
Arrays, Pointers and Memory Management EECS 2031 Summer 2014 Przemyslaw Pawluk May 20, 2014 Answer to the question from last week strct->field Returns the value of field in the structure pointed to by
More informationDynamic memory allocation (malloc)
1 Plan for today Quick review of previous lecture Array of pointers Command line arguments Dynamic memory allocation (malloc) Structures (Ch 6) Input and Output (Ch 7) 1 Pointers K&R Ch 5 Basics: Declaration
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationSubject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100
Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space
More informationVariation 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 informationComputers in Engineering. Moving From Fortran to C Michael A. Hawker
Computers in Engineering COMP 208 Moving From Fortran to C Michael A. Hawker Remember our first Fortran program? PROGRAM hello IMPLICIT NONE!This is my first program WRITE (*,*) "Hello, World!" END PROGRAM
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 9 Pointer Department of Computer Engineering 1/46 Outline Defining and using Pointers
More informationDC54 DATA STRUCTURES DEC 2014
Q.2 a. Write a function that computes x^y using Recursion. The property that x^y is simply a product of x and x^(y-1 ). For example, 5^4= 5 * 5^3. The recursive definition of x^y can be represented as
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationKurt Schmidt. October 30, 2018
to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed
More informationPointers. Introduction
Pointers Spring Semester 2007 Programming and Data Structure 1 Introduction A pointer is a variable that represents the location (rather than the value) of a data item. They have a number of useful applications.
More informationUnit 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 informationC-Programming. Claude Fuhrer 5 août 2017
C-Programming Claude Fuhrer (claude.fuhrer@bfh.ch) 5 août 2017 1 Pseudocode The most important step in writing a program, is to understand the problem which should be solved and then establish a strategy
More informationLab Exam 1 D [1 mark] Give an example of a sample input which would make the function
CMPT 127 Spring 2019 Grade: / 20 First name: Last name: Student Number: Lab Exam 1 D400 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return -1? Answer:
More informationCCE RR REVISED & UN-REVISED KARNATAKA SECONDARY EDUCATION EXAMINATION BOARD, MALLESWARAM, BANGALORE G È.G È.G È..
CCE RR REVISED & UN-REVISED B O %lo ÆË v ÃO y Æ fio» flms ÿ,» fl Ê«fiÀ M, ÊMV fl 560 003 KARNATAKA SECONDARY EDUCATION EXAMINATION BOARD, MALLESWARAM, BANGALORE 560 003 G È.G È.G È.. Æ fioê, d È 2018 S.
More informationQUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:
QUIZ 1. Explain the meaning of the angle brackets in the declaration of v below: This is a template, used for generic programming! QUIZ 2. Why is the vector class called a container? 3. Explain how the
More informationMidterm Examination # 2 Wednesday, March 18, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:
Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 2 Wednesday, March 18, 2015 ANSWERS Duration of examination: 75 minutes STUDENT
More informationIntroduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language
Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also
More informationOperators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur
Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators
More informationProgramming for Engineers Arrays
Programming for Engineers Arrays ICEN 200 Spring 2018 Prof. Dola Saha 1 Array Ø Arrays are data structures consisting of related data items of the same type. Ø A group of contiguous memory locations that
More informationUNIT 3 OPERATORS. [Marks- 12]
1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,
More informationLesson 7. Reading and Writing a.k.a. Input and Output
Lesson 7 Reading and Writing a.k.a. Input and Output Escape sequences for printf strings Source: http://en.wikipedia.org/wiki/escape_sequences_in_c Escape sequences for printf strings Why do we need escape
More informationIntroduction to C. Systems Programming Concepts
Introduction to C Systems Programming Concepts Introduction to C A simple C Program Variable Declarations printf ( ) Compiling and Running a C Program Sizeof Program #include What is True in C? if example
More informationAdvanced 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 informationCOMP26120: Pointers in C (2018/19) Lucas Cordeiro
COMP26120: Pointers in C (2018/19) Lucas Cordeiro lucas.cordeiro@manchester.ac.uk Organisation Lucas Cordeiro (Senior Lecturer, FM Group) lucas.cordeiro@manchester.ac.uk Office: 2.44 Office hours: 10-11
More information