Guide for The C Programming Language Chapter 5
|
|
- Maude Summers
- 6 years ago
- Views:
Transcription
1 1. Differentiate between primitive data type and non-primitive data type. Primitive data types are the basic data types. These data types are used to represent single values. For example: Character, Integer, Float, Double etc. Data types that are derived from basic data types are known as non-primitive data types. These data types are used to store group of data. For example: Array, Structure, Union, Queue, Stack etc. 2. What is a pointer? Explain how the pointer variable is declared and initialized. A pointer is a variable that contains the address of a variable. Syntax of declaration of pointer: datatype *pointername; For example: int *ip; /* data type is integer and pointer name is ip.*/ char *cp; /* data type is character and pointer name is cp.*/ Initialization of pointer: Initialization is the assigning of address of a variable to a pointer variable. For example: int a=5; int *ip; ip=&a; where & is the unary operator gives the address of an object. 3. Explain preprocessor directives in C with example. The #define is a macro preprocessor directive. Syntax of #define directive: #define identifier token-string OR #define identifier (identifier-list) token-string The #define directive causes compiler to substitute the token-string for each occurrence of the identifier in the source file. The token-string may consist of a series of token such as constant, keyword or complete sentence. Example: #define PI 3.14 #undef is a macro preprocessor directive. Syntax of #undef directive: #undef identifier The #undef directive removes the current definition of the identifier and subsequent occurrence of the identifier is ignored by the processor. Page: 1
2 Example: #define AGE #undef AGE The #include directive loads a specific file to the program. Syntax of #include directive: (a) #include <filename> It causes the replacement of the line by the entire content of file filename. The search for the file is made in the standard directories. (b) #include filename It causes the replacement of the line by the entire content of file filename. The search for the file is made in the current directory and standard directories. For example: #include <stdio.h> Conditional Compilation: Parts of the program may be compiled conditionally. The compiler compiles selected portion of the program based on the condition. #ifdef and # are conditional compilation directive. Syntax: #ifdef <identifier> statment1; statement2; # statment3; statement4; #endif If the identifier is defined, then #if block is compiled. If the identifier is not defined, then # block is compiled. For example: #include <stdio.h> #define PI 3.14 float radius,area; printf( \nenter the radius of the circle: ); scanf( %f,&radius); #ifdef PI Page: 2
3 area=pi*radius*radius; # area=3.14*radius*radius; #endif printf( \n Area of the circle:%0.2f,area); If the PI is defined, then #if block is compiled. If the PI is not defined, then # block is compiled. 4. Write a C program to swap two numbers using call by pointers (address) method. void swap(int *m, int *n); int a=2,b=3; printf( \n Before the function call: a=%d and b=%d\n,a,b); swap(&a,&b); printf( \n After the function call: a=%d and b=%d\n,a,b); void swap(int *m, int *n) int *r; *r=*m; *m=*n; *n=*r; 5. Explain how pointers and arrays are related with examples. There is a strong relationship between pointers and arrays. An operation that can be performed by arrays can also achieved by pointers. Consider the declaration of the array below: int a[5]; defines an array of size 5. A block of consecutive elements named a[0],a[1],a[2],a[3],a[4]. a[0] a[1] a[2] a[3] a[4] The notation a[i] refers to the i th element of the array. Now, let us declare a pointer as below: int *ptr; Then, the assignment ptr=&a[0]; Page: 3
4 sets ptr to point to the element a[0] of the array. ptr contains the address of a[0]. a[i] can be written as *(ptr+i). ptr ptr+1 ptr+2 ptr+3 ptr+4 a[0] a[1] a[2] a[3] a[4] Further, ptr=&a[0] can also be written as ptr=a ; and (ptr+i) can be written as (a+i). Hence, a[i] can be written as *(ptr+i) and a[i] can also be written as *(a+i). 6. Write C programs to define macros for (i) arithmetic operator(ii)logical operators. (i) #define multiply(a,b) a*b int x,y,res; printf( \n Enter two integers: ); scanf( %d %d, &x, &y); res=multiply(x,y); printf( \n Result=%d,res); (ii) #define LOGIC_AND (a,b) a&&b int x,y,res; printf( \n Enter two boolean(0 or 1) ); scanf( %d %d, &x, &y); res=logic_and(x,y); printf( \n Result=%d,res); 7. Write a C program using pointers to compute the Sum, Mean and Standard deviation of n elements stored in an array of n real numbers. #include<math.h> Page: 4
5 float sum=0, mean=0, std=0, s=0; float arr[100], *p; int i,n; printf( \n Enter the number of elements: ); scanf( %d,&n); for(i=0; i<n; i++) scanf( %f, arr+i); p=arr; for(i=0; i<n; i++) sum=sum+*p; p=p+1; mean= sum/n; p=arr; for(i=0; i<n; i++) s=s + (*p-mean)*(*p-mean); p=p+1; std=sqrt(s/n); printf( \n sum=%0.2f,sum); printf( \n mean=%0.2f,mean); printf( \n standard deviation=%0.2f,std); 8. Explain the array of pointers with example. Since pointers are variables, they can be stored in arrays similar to any other variables. For example: #include <stdio.h> int i; int arr[5]=5,6,7,8,9; int *ptr[5]; for(i=0; i<5; i++) ptr[i]=&arr[i]; for(i=0; i<5; i++) printf( \n arr[%d]=%d, i,*ptr[i]); Page: 5
6 9. What is dynamic memory allocation? What is the need for dynamic memory allocation? Dynamic memory allocation enables the programmer to allocate memory at runtime. This allows the programmer to obtain more memory when required and to release the memory when it is not required. Dynamic memory allocation prevents the wastage of memory. A lot of memory is wasted in static memory allocation because all the memory allocated may not be utilized. 10. Explain the functions for dynamic memory allocation in C. Following are the dynamic memory allocation functions: malloc():this function is used to allocate a block of memory in bytes. Syntax for this function is: ptr=malloc(number of elements*size of the elements); Type of pointer returns is void. Therefore, typecast is required. For example: #include<stdlib.h> int i; int *ptr; ptr=(int *)malloc( 5*sizeof(int)); printf( \n Enter 5 integers: ); for(i=0; i<5; i++) scanf( %d, ptr+i); printf( \n Output: ); for(i=0; i<5; i++) printf( %d,*(ptr+i)); free(ptr); calloc():this function allocate a block of memory for an array. It initializes all bits to 0. Syntax: ptr=calloc(number of elements, size of each element); For example: #include<stdlib.h> int i; int *ptr; ptr=(int *)calloc( 5,sizeof(int)); Page: 6
7 printf( \n Enter 5 integers: ); for(i=0; i<5; i++) scanf( %d, ptr+i); printf( \n Output: ); for(i=0; i<5; i++) printf( %d,*(ptr+i)); free(ptr); realloc(): This function is used to resize the memory which is already allocated. Syntax: ptr=realloc(ptr, new size); For example: #include<stdlib.h> int i; int *ptr; ptr=(int *)malloc( 5*sizeof(int)); ptr=(int *)realloc( ptr,6*sizeof(int)); printf( \n Enter 6 integers: ); for(i=0; i<6; i++) scanf( %d, ptr+i); printf( \n Output: ); for(i=0; i<6; i++) printf( %d,*(ptr+i)); free(ptr); free(): This function is used to de-allocate previously allocated memory. Syntax: Free(ptr); Example: Any of the above example for malloc(), calloc() or realloc(); 11. Explain Stack and Queue data structures along with their applications. Stack is a linear data structure. We can insert or delete an element from one end. We may perform LIFO (Last In First Out) or FILO (First In Last out). The insertion operation of an element onto the stack is called as push and deletion operation is called pop. The end where the insertion or deletion takes place is called top. Page: 7
8 4 Top of stack Application of stack: (i) Expression evaluation. (ii)expression conversion, for example, Infix to postfix conversion (iii) Redo-Undo operation (iv) Forward and backward features of web browsers. (v) Used in algorithms like tree traversals, span problem etc (vi) Applications like Backtracking, Queen problem etc. (vii) Parsing (viii)simulation of recursion. Queue is a linear data structure. It is a homogeneous collection of elements in which elements are appended in one end called rear end and elements are deleted at other end called front end. Queue follows FIFO (First In First Out). Application of Queue: (i) Queue is used in operating systems maintain a queue of processes that are waiting for execution. (ii) Queue is used where data is transferred asynchronously between two processes. For example, buffer. (iii) Queue is used for sharing resource among different consumers. (ii) Breadth First Search uses queue. (iii) Queue is performs jobs in a network printer. 12. Write a C program using array to demonstrate the operations on stack. #define MAX 100 void push(); void pop(); void disp(); int stack[max]; int top=-1; int choice; clrscr(); while(1) Page: 8
9 printf( \n 1.Insert element to the stack ); printf( \n 1.Delete element from the stack ); Printf( \n 1.Display elements of the stack ); printf( \n 4.Quit ); printf( \n Enter your choice: ); scanf( %d,&choice); switch(choice) case 1: push(); case 2: pop(); case 3: disp(); case 4: exit(0); default: printf( \n Wrong choice ); void push() int item; if (top=max-1) printf( \n Stack is full ); printf( \n Enter the element to be inserted: ); scanf( %d,&item); top=top+1; stack[top]=item; void pop() if(top==-1) printf( \n Stack is empty ); Page: 9
10 printf( \n Element deleted from the stack is :%d, stack[top]); top=top-1; void disp() int i; if(top==-1) printf( \n Stack is empty. ); printf( \n Stack is: ); for(i=top; i>=0; i--) printf( %d, stack[i]); print( \n ); 13. Write a C program using link list to demonstrate the operations on stack. #include <stdio.h> #include<stdlib.h> struct node int info; struct node *next; ; typedef struct node NODEPTR; NODEPTR top,temp; void push(); void pop(); void disp(); int choice; clrscr(); while(1) printf( \n 1.Insert element to the stack ); printf( \n 2.Delete element from the stack ); printf( \n 3.Display elements of the stack ); Page: 10
11 printf( \n 4.Quit ); printf( \nenter your choice: ); scanf( %d,&choice); switch(choice) case 1; push(); case 2; pop(); case 3; disp(); case 4; exit(0); default: printf( \n Wrong choice ); void push() int item; printf( \nenter the element to be inserted: ); scanf( %d,&item); if(top==null) top=(nodeptr)malloc(sizeof(struct node)); top->next=null; top->info=item; temp=(nodeptr)malloc(sizeof(struct node)); temp->next=top; temp->info=item; top=temp; Page: 11
12 void pop() if(top==null) printf( \nerror:stack is empty ); if(top->next!=null) temp=top->next; printf( \nelement deleted from the stack is:%d, top->info); free(top); top=temp; printf( \nelement deleted from the stack is:%d, top->info); free(top); top=null; void disp() temp=top; if(top==null) printf( \nstack is empty. ); printf( Stack is: ); while(temp!=null) printf( %d,temp->info); temp=temp->next; printf( \n ); 14. Write a C program using array to demonstrate the operations on queue. #define MAX 100 void insert(); void del(); Page: 12
13 void disp(); int queue[max]; int rear=-1; int front=-1; int choice; clrscr(); while(1) printf( \n 1.Insert element to the queue ); printf( \n 1.Delete element from the queue ); Printf( \n 1.Display elements of the queue ); printf( \n 4.Quit ); printf( \n Enter your choice: ); scanf( %d,&choice); switch(choice) case 1: insert(); case 2: del(); case 3: disp(); case 4: exit(0); default: printf( \n Wrong choice ); void insert() int item; if (rear=max-1) printf( \n Queue overflows); Page: 13
14 if(front==-1) front=0; printf( \n Enter the element to be inserted: ); scanf( %d,&item); rear=rear+1; queue[rear]=item; void del() if(front==-1 front>rear) printf( \n Queue is empty ); printf( \n Element deleted from the queue is :%d, queue[front]); front=front+1; void disp() int i; if(front==-1) printf( \n Queue is empty. ); printf( \n Queue is: ); for(i=front; i<=rear; i++) printf( %d, queue[i]); print( \n ); 15. Write a C program using link list to demonstrate the operations on queue. #include <stdio.h> #include<stdlib.h> Page: 14
15 struct node int info; struct node *next; ; typedef struct node NODEPTR; NODEPTR front,rear,temp; void insert(); void del(); void disp(); int choice; clrscr(); while(1) printf( \n 1.Insert element to the queue ); printf( \n 2.Delete element from the queue ); printf( \n 3.Display elements of the queue ); printf( \n 4.Quit ); printf( \nenter your choice: ); scanf( %d,&choice); switch(choice) case 1; insert(); case 2; del(); case 3; disp(); case 4; exit(0); default: printf( \n Wrong choice ); Page: 15
16 void insert() int item; printf( \nenter the element to be inserted: ); scanf( %d,&item); if(rear==null) rear=(nodeptr)malloc(sizeof(struct node)); rear->next=null; rear->info=item; front=rear; temp=(nodeptr)malloc(sizeof(struct node)); rear->next=temp; temp->info=item; temp->next=null; rear=temp; void del() if(front==null) printf( \nerror:queue is empty ); if(front->next!=null) temp=front->next; printf( \n Element deleted from the queue is:%d, front->info); free(front); front=temp; printf( \n Element deleted from the queue is:%d, front->info); free(front); front=null; rear=null; Page: 16
17 void disp() temp=front; if(front==null) printf( \nqueue is empty. ); printf( Queue is: ); while(temp!=rear->next) printf( %d,temp->info); temp=temp->next; printf( \n ); 16. What is tree data structure? State the application of tree data structure. A tree is hierarchical data structure. It is a set of entities called nodes. Nodes are connected by edges. Each node contains data. First node of the tree is called the root. Applications of tree data structure are: (i) Manipulation of data which are arranged in hierarchical manner. (ii)search for data easily. (iii)prepare sorted list of data easily. (iv)router algorithm (v) Operating system maintains disk file system as a tree. (vi) Trees are used in language processing programs. Page: 17
A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS
Syllabus: Pointers and Preprocessors: Pointers and address, pointers and functions (call by reference) arguments, pointers and arrays, address arithmetic, character pointer and functions, pointers to pointer,initialization
More informationMODULE 5: Pointers, Preprocessor Directives and Data Structures
MODULE 5: Pointers, Preprocessor Directives and Data Structures 1. What is pointer? Explain with an example program. Solution: Pointer is a variable which contains the address of another variable. Two
More informationMODULE V: POINTERS & PREPROCESSORS
MODULE V: POINTERS & PREPROCESSORS INTRODUCTION As you know, every variable is a memory-location and every memory-location has its address defined which can be accessed using ampersand(&) operator, which
More informationCS6202 - PROGRAMMING & DATA STRUCTURES I Unit IV Part - A 1. Define Stack. A stack is an ordered list in which all insertions and deletions are made at one end, called the top. It is an abstract data type
More informationNCS 301 DATA STRUCTURE USING C
NCS Data Structure Using C -8- NCS DATA STRUCTURE USING C Unit- Part- Stack Hammad Mashkoor Lari Assistant Professor Allenhouse Institute of Technology www.ncsds.wordpress.com Introduction Stack is a non
More informationClass / Sem: I CSE / II Semester Subject Code: CS 6202 Subject: Programming and Data Structures I Prepared by T. Vithya Unit IV - LINEAR DATA STRUCTURES STACKS AND QUEUES Stack ADT Evaluating arithmetic
More informationCSCI 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 informationDEEPIKA KAMBOJ UNIT 2. What is Stack?
What is Stack? UNIT 2 Stack is an important data structure which stores its elements in an ordered manner. You must have seen a pile of plates where one plate is placed on top of another. Now, when you
More informationFor Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit
For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/ For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/
More informationSTACKS 3.1 INTRODUCTION 3.2 DEFINITION
STACKS 3 3.1 INTRODUCTION A stack is a linear data structure. It is very useful in many applications of computer science. It is a list in which all insertions and deletions are made at one end, called
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationPointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017
Pointers (part 1) EECS 2031 25 September 2017 1 What are pointers? We have seen pointers before. scanf( %f, &inches );! 2 1 Example char c; c = getchar(); printf( %c, c); char c; char *p; c = getchar();
More informationPrepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon
Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements
More informationDS Assignment II. Full Sized Image
DS Assignment II 1. A) For the Towers of Hanoi problem, show the call tree during the recursive call Towers(3, A, C, B). In the tree, label the root node as Towers (3, A, C, B) while marking all the intermediate
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 information1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \
BSc IT C Programming (2013-2017) Unit I Q1. What do you understand by type conversion? (2013) Q2. Why we need different data types? (2013) Q3 What is the output of the following (2013) main() Printf( %d,
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 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 informationPERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam Thanjavur
PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam-613 403 Thanjavur 01. Define program? 02. What is program development cycle? 03. What is a programming language? 04. Define algorithm? 05. What
More informationLinear Data Structure
Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal
More informationContent: Learning Objectives
1 BLOOM PUBLIC CHOOL Vasant Kunj, New Delhi Lesson Plan Class: XII ubject: Computer cience Month : July No of s: 21 Chapter:Data structure: Linked List TTT: 8 WT: 12 Content: Learning Objectives At the
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 informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE
TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)
More informationThe Queues. Front. Rear. Front. Rear. Rear = 0 Front = 0. Fig Queue is empty. Fig push(10) Rear = 1 Front = 0. Fig. 4.3.
4 The Queues A queue is logically a first in first out (FIFO or first come first serve) linear data structure. The concept of queue can be understood by our real life problems. For example a customer come
More informationNCS 301 DATA STRUCTURE USING C
NCS 301 Data Structure Using C NCS 301 DATA STRUCTURE USING C Unit-1 Part-1 Intro to Data Structures Hammad Mashkoor Lari Assistant Professor Allenhouse Institute of Technolgy www.ncs301ds.wordpress.com
More informationCP2 Revision. theme: dynamic datatypes & data structures
CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;
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 informationProcedural programming with C
Procedural programming with C Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 77 Functions Similarly to its mathematical
More informationArrays 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 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 informationLecture 4 Stack and Queue
Lecture 4 Stack and Queue Bo Tang @ SUSTech, Spring 2018 Our Roadmap Stack Queue Stack vs. Queue 2 Stack A stack is a sequence in which: Items can be added and removed only at one end (the top) You can
More informationFirst 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 informationArrays and Pointers (part 1)
Arrays and Pointers (part 1) CSE 2031 Fall 2010 17 October 2010 1 Arrays Grouping of data of the same type. Loops commonly used for manipulation. Programmers set array sizes explicitly. 2 1 Arrays: Example
More informationBangalore South Campus
USN: 1 P E PESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities INTERNAL ASSESSMENT TEST 3 Date: 22/11/2017 Time:11:30am- 1.00 pm
More informationCS PROGRAMMING & DATA STRUCTURES. UNIT I Part - A. 2. What is the difference between if and while statement?
CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. What 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 informationIMPORTANT 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 informationPointers. Part VI. 1) Introduction. 2) Declaring Pointer Variables. 3) Using Pointers. 4) Pointer Arithmetic. 5) Pointers and Arrays
EE105: Software Engineering II Part 6 Pointers page 1 of 19 Part VI Pointers 1) Introduction 2) Declaring Pointer Variables 3) Using Pointers 4) Pointer Arithmetic 5) Pointers and Arrays 6) Pointers and
More informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
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 informationDATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305
Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n
More informationProgramming and Data Structure Solved. MCQs- Part 2
Programming and Data Structure Solved MCQs- Part 2 Programming and Data Structure Solved MCQs- Part 2 Unsigned integers occupies Two bytes Four bytes One byte Eight byte A weather forecasting computation
More informationCode No: R Set No. 1
Code No: R05010106 Set No. 1 1. (a) Draw a Flowchart for the following The average score for 3 tests has to be greater than 80 for a candidate to qualify for the interview. Representing the conditional
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours
TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART
More informationPreface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS
Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...
More informationOutline. Briefly review the last class Pointers and Structs Memory allocation Linked lists
Outline Briefly review the last class Pointers and Structs Memory allocation Linked lists C Structures and Memory Allocation A struct is a data structure that comprises multiple types, each known as a
More informationPostfix (and prefix) notation
Postfix (and prefix) notation Also called reverse Polish reversed form of notation devised by mathematician named Jan Łukasiewicz (so really lü-kä-sha-vech notation) Infix notation is: operand operator
More informationDEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS 1. Define global declaration? The variables that are used in more
More informationIntroduction 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 informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationMemory 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 informationP.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above
P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above
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 themodel answer scheme. 2) The model answer and the answer written by candidate may
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 informationChapter 6. Data Structure. /* start contains the address of the first node */ start = &elephant1; print_elephants( start ); return EXIT_SUCCESS;
Chapter 6 Data Structure Introductory notes are included in PowerPoint file. The programs illustrated are as follows: //elephnt1.c // This example is from C for Scientists and Engineers #include
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure using C Model wer Subject Code: 22317 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given
More informationEM108 Software Development for Engineers
EE108 Section 6 Pointers page 1 of 20 EM108 Software Development for Engineers Section 6 - Pointers 1) Introduction 2) Declaring Pointer Variables 3) Using Pointers 4) Pointer Arithmetic 5) Pointers and
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 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 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 informationPESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities
INTERNAL ASSESSMENT TEST-3 Date : 12-05-2016 Marks: 40 Subject & Code : Programming in C and data structures (15PCD23) Sec : F,G,H,I,J,K Name of faculty :Dr J Surya Prasad/Mr.Sreenath M V/Ms.Monika/ Time
More informationLecture Data Structure Stack
Lecture Data Structure Stack 1.A stack :-is an abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example a deck of cards
More informationActually, C provides another type of variable which allows us to do just that. These are called dynamic variables.
When a program is run, memory space is immediately reserved for the variables defined in the program. This memory space is kept by the variables until the program terminates. These variables are called
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationCS240: Programming in C
CS240: Programming in C Lecture 6: Recursive Functions. C Pre-processor. Cristina Nita-Rotaru Lecture 6/ Fall 2013 1 Functions: extern and static Functions can be used before they are declared static for
More informationCS113: Lecture 5. Topics: Pointers. Pointers and Activation Records
CS113: Lecture 5 Topics: Pointers Pointers and Activation Records 1 From Last Time: A Useless Function #include void get_age( int age ); int age; get_age( age ); printf( "Your age is: %d\n",
More informationFrom Java to C. Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides
From Java to C Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides 1 Outline Overview comparison of C and Java Good evening Preprocessor
More informationC Pointers. Abdelghani Bellaachia, CSCI 1121 Page: 1
C Pointers 1. Objective... 2 2. Introduction... 2 3. Pointer Variable Declarations and Initialization... 3 4. Reference operator (&) and Dereference operator (*) 6 5. Relation between Arrays and Pointers...
More informationA3-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 informationSAURASHTRA UNIVERSITY
SAURASHTRA UNIVERSITY RAJKOT INDIA Accredited Grade A by NAAC (CGPA 3.05) CURRICULAM FOR B.Sc. (Computer Science) Bachelor of Science (Computer Science) (Semester - 1 Semester - 2) Effective From June
More informationM4.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 informationDarshan Institute of Engineering & Technology for Diploma studies Unit 4
Pointer A pointer is a variable that contains address or location of another variable. Pointer is a derived data type in C. Pointers contain memory address as their values, so they can also be used to
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 informationC Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:
C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should
More informationTechnical Questions. Q 1) What are the key features in C programming language?
Technical Questions Q 1) What are the key features in C programming language? Portability Platform independent language. Modularity Possibility to break down large programs into small modules. Flexibility
More informationThis document can be downloaded from with most recent updates. 1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS
1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS 4.1 MEMORY MANAGEMENT 4.1.1 Basics about Memory When a C program is compiled, the compiler translates the source code into machine code. Now the
More informationArrays and Pointers. CSE 2031 Fall November 11, 2013
Arrays and Pointers CSE 2031 Fall 2013 November 11, 2013 1 Arrays l Grouping of data of the same type. l Loops commonly used for manipulation. l Programmers set array sizes explicitly. 2 Arrays: Example
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 informationJTSK Programming in C II C-Lab II. Lecture 3 & 4
JTSK-320112 Programming in C II C-Lab II Lecture 3 & 4 Xu (Owen) He Spring 2018 Slides modified from Dr. Kinga Lipskoch Planned Syllabus The C Preprocessor Bit Operations Pointers and Arrays (Dynamically
More informationComputer Programming Unit 3
POINTERS INTRODUCTION Pointers are important in c-language. Some tasks are performed more easily with pointers such as dynamic memory allocation, cannot be performed without using pointers. So it s very
More informationi location name 3 value at location 6485 location no.(address)
POINTERS The & and * operators. Consider the declaration, int i = 3; i location name 3 value at location 6485 location no.(address) This declaration tells the C compiler to: (a)reserve space in memory
More information[0569] p 0318 garbage
A Pointer is a variable which contains the address of another variable. Declaration syntax: Pointer_type *pointer_name; This declaration will create a pointer of the pointer_name which will point to the
More informationProblem Solving and 'C' Programming
Problem Solving and 'C' Programming Targeted at: Entry Level Trainees Session 15: Files and Preprocessor Directives/Pointers 2007, Cognizant Technology Solutions. All Rights Reserved. The information contained
More informationDC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?
Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link
More informationIntroduction to Data Structures and Algorithms
Introduction to Data Structures and Algorithms Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. Data Structures
More informationAMCAT 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 informationQuick review pointer basics (KR ch )
1 Plan for today Quick review pointer basics (KR ch5.1 5.5) Related questions in midterm Continue on pointers (KR 5.6 -- ) Array of pointers Command line arguments Dynamic memory allocation (malloc) 1
More informationIn Java we have the keyword null, which is the value of an uninitialized reference type
+ More on Pointers + Null pointers In Java we have the keyword null, which is the value of an uninitialized reference type In C we sometimes use NULL, but its just a macro for the integer 0 Pointers are
More informationCpt S 122 Data Structures. Data Structures
Cpt S 122 Data Structures Data Structures Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Self Referential Structures Dynamic Memory Allocation
More informationCSE2301. Dynamic memory Allocation. malloc() Dynamic Memory Allocation and Structs
Warning: These notes are not complete, it is a Skelton that will be modified/add-to in the class. If you want to us them for studying, either attend the class or get the completed notes from someone who
More informationArrays and Pointers. Arrays. Arrays: Example. Arrays: Definition and Access. Arrays Stored in Memory. Initialization. EECS 2031 Fall 2014.
Arrays Arrays and Pointers l Grouping of data of the same type. l Loops commonly used for manipulation. l Programmers set array sizes explicitly. EECS 2031 Fall 2014 November 11, 2013 1 2 Arrays: Example
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in
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 informationPrepared by Mrs.D.Maladhy (AP/IT/RGCET) Page 1
Basics : Abstract Data Type(ADT) introduction to data structures representation - implementation Stack and list: representing stack implementation application balancing symbols conversion of infix to postfix
More informationScheme of valuations-test 3 PART 1
Scheme of valuations-test 3 PART 1 1 a What is string? Explain with example how to pass string to a function. Ans A string constant is a one-dimensional array of characters terminated by a null ( \0 )
More informationHigh Performance Programming Programming in C part 1
High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the
More informationFundamentals of Programming
Fundamentals of Programming Pointers Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) Pointers February 29, 2012 1
More informationPointers and File Handling
1 Pointers and File Handling From variables to their addresses Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR 2 Basics of Pointers INDIAN INSTITUTE OF TECHNOLOGY
More informationAE52/AC52/AT52 C & Data Structures JUNE 2014
Q.2 a. Write a program to add two numbers using a temporary variable. #include #include int main () int num1, num2; clrscr (); printf( \n Enter the first number : ); scanf ( %d, &num1);
More informationBasic and Practice in Programming Lab7
Basic and Practice in Programming Lab7 Variable and Its Address (1/2) What is the variable? Abstracted representation of allocated memory Having address & value Memory address 10 0x00000010 a int a = 10;
More 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 information