PESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities
|
|
- Imogen Flowers
- 6 years ago
- Views:
Transcription
1 INTERNAL ASSESSMENT TEST-3 Date : 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 :11.30 am to 1.00 Ms.Swati/Ms.Bhuvaneswari pm Note: Answer FIVE full questions, selecting any ONE full question from each part. PART 1 1 a What is structure? Explain the syntax of structure declaration with example. Structure is a collection of elements of different data type. The syntax is shown below: struct structure_name data_type member1; data_type member2; data_type member3; ; The variables that are used to store the data are called members of the structure. We can create the structure for a person as shown below: struct person char name[50]; int cit_no; float salary; ; This declaration above creates the derived data type struct person. b What is file? Explain how the file open and file close function handled in C. DEFINING, OPENING AND CLOSING OF FILES A file represents a sequence of bytes, regardless of it being a text file or a binary file. Defining a File While working with file, you need to declare a pointer of type FILE. This declaration is needed for communication between file and program. FILE *ptr; Opening a File fopen( ) function can be used to create a new file or to open an existing file This function will initialize an object of the type FILE, which contains all the information necessary to control the stream. 4 4
2 The syntax is shown below: FILE *fopen( const char *filename, const char *access_mode ); where filename is string literal, which you will use to name your file. access_mode can have one of the following values: Mode Description r Opens an existing text file for reading purpose w Opens a text file for writing, if it does not exist then a new file is created a Opens a text file for writing in appending mode r+ Opens a text file for reading and writing both Closing a File The file should be closed after reading/writing of a file. fclose( ) function can be used to close a file. The syntax is shown below: int fclose(file *fp); The fclose( ) function returns zero on success or returns EOF(special character) if there is an error 2 Explain how to pass structure to function by value and by address. passing structure to function in C by value: In this program, the whole structure is passed to another function by value. It means the whole structure is passed to another function with all members and their values. So, this structure can be accessed from called function. This concept is very useful while writing very big programs in C. 8 #include <stdio.h> #include <string.h> struct student int id; char name[20]; float percentage; ; void func(struct student record);
3 int main() struct student record; record.id=1; strcpy(record.name, "Raju"); record.percentage = 86.5; func(record); return 0; void func(struct student record) printf(" Id is: %d \n", record.id); printf(" Name is: %s \n", record.name); printf(" Percentage is: %f \n", record.percentage); Passing structure to function in C by address: In this program, the whole structure is passed to another function by address. It means only the address of the structure is passed to another function. The whole structure is not passed to another function with all members and their values. So, this structure can be accessed from called function by its address. #include <stdio.h> #include <string.h> struct student
4 int id; char name[20]; float percentage; ; void func(struct student *record); int main() struct student record; record.id=1; strcpy(record.name, "Raju"); record.percentage = 86.5; func(&record); return 0; void func(struct student *record) printf(" Id is: %d \n", record->id); printf(" Name is: %s \n", record->name); printf(" Percentage is: %f \n", record->percentage); PART 2 3 Write a C program to maintain a record of N student detail using an array of structures with four fields (USN, Name, Marks, and Grade).Each field is of appropriate data type. Print the marks of the student, given student name as input. 8
5 #include <stdio.h> #include <stdlib.h> struct Student int Marks,RollNo; char Name[30],Grade; ; void main() struct Student s[20]; int i, Num, Found = 0; char StudName[30]; printf("\nenter the number of students\n"); scanf("%d", &Num); printf("\nenter Student Details\n"); for(i=0;i<num;i++) printf("\nstudent %d\n\nrollno : ", i+1); scanf("%d", &s[i].rollno); printf("\nname : "); scanf("%s",&s[i].name); printf("\nmarks : "); scanf("%d",&s[i].marks); printf("\ngrade : "); scanf("%s",&s[i].grade); printf("\n\n\n"); printf("\nenter the name to display marks\n"); scanf("%s",&studname); for(i=0;i<num;i++) if(strcmp(studname,s[i].name)==0)
6 Found = 1; printf("\nmarks obtained by %s is %d\n", s[i].name, s[i].marks); exit(0); if(found == 0) printf("\nno student by name %s found\n", StudName); 4 a Write a C program to add two complex numbers by passing structure to a function. 8 #include <stdio.h> struct complex float real; float imag; ; struct complex add(struct complex n1,struct complex n2); int main() struct complex n1,n2,n_sum; printf("for 1st complex number \n"); printf("enter real and imaginary respectively:\n"); scanf("%f%f",&n1.real,&n1.imag); printf("\nfor 2nd complex number \n"); printf("enter real and imaginary respectively:\n"); scanf("%f%f",&n2.real,&n2.imag); n_sum=add(n1,n2); printf("sum=%f+%fi",n_sum.real,n_sum.imag);
7 getch(); return 0; struct complex add(struct complex n1,struct complex n2) struct complex temp; temp.real=n1.real+n2.real; temp.imag=n1.imag+n2.imag; return(temp); PART 3 5 Given two university information files studentname.txt and usn.txt that containsstudents Name and USN respectively. Write a C program to create a new file called output.txt and copy the content of files studentname.txt and usn.txt into output file. Display the contents of output file output.txt on tothe screen. 8 #include<stdio.h> #include<stdlib.h> main() FILE *fp1,*fp2,*fp3; char usn[10],name[20]; fp1=fopen("studentname.txt","r"); if(fp1==null) printf("\n Error opening studentname.txt\n"); exit(0); fp2=fopen("usn.txt","r"); if(fp2==null) printf("\n Error opening usn.txt\n"); exit(0);
8 fp3=fopen("output.txt","w"); if(fp2==null) printf("\n Error opening output.txt\n"); exit(0); while(!feof(fp1) &&!feof(fp2) ) fscanf(fp1,"%s",name); fscanf(fp2,"%s",usn); fprintf(fp3,"%s \t %s \n",name,usn); fclose(fp1); fclose(fp2); fclose(fp3); fp3=fopen("output.txt","r"); printf("\nname \t USN \n\n"); while(!feof(fp3) ) fscanf(fp3,"%s",name); fscanf(fp3,"%s",usn); printf("%s \t %s \n",name,usn); fclose(fp3); 6 a What is a pointer? Explain how the pointer variable declared and initialized. A pointer is a variable which holds address of another variable or a memory-location. For ex: c=300; pc=&c; Here pc is a pointer; it can hold the address of variable c & is called reference operator DECLARATION OF POINTER VARIABLE Dereference operator(*) are used for defining pointer-variable. The syntax is shown below: data_type *ptr_var_name; For ex: 4
9 int *a; // a as pointer variable of type int float *c; // c as pointer variable of type float Steps to access data through pointers: 1) Declare a data-variable ex: int c; 2) Declare a pointer-variable ex: int *pc; 3) Initialize a pointer-variable ex: pc=&c; 4) Access data using pointer-variable ex: printf("%d",*pc); Code int* pc; creates a pointer pc and code int c; Code c=22; makes the value of c equal to 22, Code pc=&c; makes pointer, point to address of c. b Explain storage classes in C. There are following storage classes which can be used in a C Program auto register static extern Auto int Count; //count is a variable that belongs to auto storage class; auto is the default storage class for all local variables. 4 variables. Register register int a; register is used to define local variables that should be stored in a register instead of RAM. This means that the variable cant have the unary '&' operator applied to it (as it does not have a memory Extern extern is used to give a reference of a global variable that is visible to ALL the program files. int count=5; main()
10 write_extern( ); File 1: main.c void write_extern(void); extern int count; void write_extern(void) printf("count is %d\n", count); File 2: write.c Static static is the default storage class for global variables. static variables can be 'seen' within all functions in this source file. At link time, the static variables defin not be seen by the object modules that are brought in. Static can also be defined within a function If this is done the variable is initalised at run time but is not reinitalized when the function is called. This inside a function static variable retains its value during vairous calls. PART 4 7 a What is dynamic memory allocation? Explain malloc and calloc dynamic allocation functions in C and also explain the difference between malloc and calloc. C Dynamic Memory Allocation: malloc(), calloc(), free() & realloc() 4 The exact size of array is unknown untill the compile time,i.e., time when a compier compiles code written in a programming language into a executable form. The size of array you have declared initially can be sometimes insufficient and sometimes more than required. Dynamic memory allocation allows a program to obtain more memory space, while running or to release space when no space is required. Although, C language inherently does not has any technique to allocated memory dynamically, there are 4 library functions under "stdlib.h" for dynamic memory allocation.
11 calloc() malloc() calloc() initializes the allocated memory with 0 value. malloc() initializes the allocated memory with garba values. Number of arguments is 2 Number of argument is 1 Syntax : (cast_type *)calloc(blocks, size_of_block); Syntax : (cast_type *)malloc(size_in_bytes); malloc() The name malloc stands for "memory allocation". This function is used to allocate the requirement memory-space during executiontime. The syntax is shown below: data_t ype *p; p=(dat a_type *)mall oc(siz e); here p is pointer variable data_type can be int, float or char size is number of bytes to be allocated If memory is successfully allocated, then address of the first byte of allocated space is returned. If memory allocation fails, then NULL is returned. For ex: ptr=(int*)malloc(100*sizeof(int)); The above statement will allocate 200 bytes assuming sizeof(int)=2 bytes. calloc() The name calloc stands for "contiguous allocation".
12 b This function is used to allocate the required memory-size during execution-time and at the same time, automatically initialize memory with 0's. The syntax is shown below: data_ty pe *p; p=(data _type*) calloc( n,size); If memory is successfully allocated, then address of the first byte of allocated space is returned. If memory allocation fails, then NULL is returned. The allocated memory is initialized automatically to 0's. For ex: ptr=(int*)calloc(25,sizeof(int)); The above statement allocates contiguous space in memory for an array of 25 elements each of size of int, i.e., 2 bytes. Write a program to find the largest of two numbers using call by pointer method. #include<stdio.h> Int * largest(int * m,int *n) If(*m>*n) Return (m); Else Return n; Void main() Int x,y; Int *p; Printf( enter two numbers ); Scanf( %d%d,&x,&y); P=largest(&x,&y); Printf( largest of two number is %d,*p); 4 8 Designs develop and execute a program in C to simulate the working of queue of integers using an array. Provide the following operations 1.Insert 2.Delete3.Display. 8
13 #include <stdio.h> #define MAX 50 int queue_array[max], rear = - 1, front = - 1; insert() int add_item; if (rear == MAX - 1) printf("queue Overflow "); else if (front == - 1) //If queue is initially empty front = 0; printf("insert the element in queue : "); scanf("%d", &add_item); rear=rear+1; queue_array[rear]=add_item; delete() if (front == - 1 front > rear) printf("queue Underflow \n"); return ; else printf("element deleted from queue is : %d\n", queue_array[front]); front = front + 1; display() int i; if (front == - 1)
14 printf("queue is empty \n"); else printf("queue is : \n"); for (i = front; i <= rear; i++) printf("%d ", queue_array[i]); printf("\n"); main() int choice; while (1) printf("1.insert element to queue \n"); printf("2.delete element from queue \n"); printf("3.display all elements of queue \n"); printf("4.quit \n"); printf("enter your choice : "); scanf("%d", &choice); switch (choice) case 1: insert(); break; case 2: delete(); break; case 3: display(); break; case 4: exit(1); default: printf("wrong choice \n"); //End of switch //End of while //End of main() PART 5
15 9 a What are primitive and non-primitive data types? PRIMITIVE AND NON-PRIMITIVE DATA TYPES Data type specifies the type of data stored in a variable. The data type can be classified into two types: 1) Primitive data type and 2)Non-Primitive data type Primitive Data Type The primitive data types are the basic data types that are available in most of the programming languages. The primitive data types are used to represent single values. Integer: This is used to represent a number without decimal point. Eg: 12, 90 Float: This is used to represent a number with decimal point. Eg: 45.1, 67.3 Character: This is used to represent single character Eg: C, a String: This is used to represent group of characters. Eg: "M.S.P.V.L Polytechnic College" Boolean: This is used represent logical values either true or false. Non Primitive Data Type The data types that are derived from primary data types are known as non-primitive data types. These datatypes are used to store group of values. The non-primitive data types are Arrays Structure Stacks Linked list Queue Binary tree 4 b What is a stack? Explain with its applications. STACKS A stack is a special type of data structure where elements are inserted from one end and elements are deleted from the same end. Using this approach, the Last element Inserted is the First element to be deleted Out, and hence, stack is also called LIFO data structure. The various operations performed on stack: Insert: An element is inserted from top end. Insertion operation is called push operation. Delete: An element is deleted from top end. Deletion operation is called pop operation. Overflow: Check whether the stack is full or not. Underflow: Check whether the stack is empty or not. 4
16 This can be pictorially represented as shown above: APPLICATIONS OF STACK 1) Conversion of expressions: The compiler converts the infix expressions into postfix expressions using stack. 2) Evaluation of expression: An arithmetic expression represented in the form of either postfix or prefix can be easily evaluated using stack. 3) Recursion: A function which calls itself is called recursive function. 4) Other applications: To find whether the string is a palindrome, to check whether a given expression is valid or not. 1 0 Write a C program to find the sum, mean and variance of all the elements in an array using pointers. #include<stdio.h> #include<math.h> 8 float findsum(float [], int); float findmean(float, int); float findstddev(float [],int,float); main() float a[20],mean,sum, stddev; int n,i; float *p; p=&a; printf("enter the No of elements \n"); scanf("%d",&n); printf("enter the elements\n"); for(i=0;i<n;i++) scanf("%f",p);
17 p++; sum=findsum(a,n); mean=findmean(sum,n); stddev=findstddev(a,n,mean); printf("\nsum: %f",sum); printf("\nmean: %f",mean); printf("\n Standard Deviation: %f",stddev); float findsum(float a[],int n) int *p; p=a; float sum=0; int i; for(i=0;i<n;i++) sum=sum + *p; p++; return sum; float findmean(float sum,int n) return sum/n;
18 float findstddev(float a[],int n,float mean) int i,*p; p=&a[0]; float stddev=0,variance,sumd=0; for(i=0; i<n;i++) sumd=sumd+pow((*p - mean),2); p++; variance=sumd/n; stddev= sqrt(variance); return stddev;
19
Bangalore 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 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 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 informationA. 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 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 informationMemory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)
Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)
More informationint marks[10]; // fixed size and fixed address No change in Memory address.
Dynamic Memory Allocation : Used When we want to allocate memory during run time. int marks[10]; // fixed size and fixed address No change in Memory address. // fixed size. ( no change in size possible
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 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 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 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 informationJagannath Institute of Management Sciences Lajpat Nagar. BCA II Sem. C Programming
Jagannath Institute of Management Sciences Lajpat Nagar BCA II Sem C Programming UNIT I Pointers: Introduction to Pointers, Pointer Notation,Decalaration and Initialization, Accessing variable through
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 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 informationProcedural Programming & Fundamentals of Programming
& Fundamentals of Programming Exercise 4 (SS 2018) 12.06.2018 What will I learn in the 5. exercise Files Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Files A file can be seen as
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 informationLab Manual B.Tech 1 st Year
Lab Manual B.Tech 1 st Year Fundamentals & Computer Programming Lab Dev Bhoomi Institute of Technology Dehradun www.dbit.ac.in Affiliated to Uttrakhand Technical University, Dehradun www.uktech.in CONTENTS
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &
More informationGuide for The C Programming Language Chapter 5
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,
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 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 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 informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More information'C' Programming Language
F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax
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 informationdynamic memory allocation
Dynamic memory allocation in C The concept of dynamic memory allocation in c language enables the C programmer to allocate memory at runtime. Dynamic memory allocation in c language is possible by 4 functions
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 informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as
More informationint Return the number of characters in string s.
1a.String handling functions: Function strcmp(const char *s1, const char *s2) strcpy(char *s1, const char *s2) strlen(const char *) strcat(char *s1, Data type returned int Task Compare two strings lexicographically.
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 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 informationGovernment Polytechnic Muzaffarpur.
Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking
More information19-Nov CSCI 2132 Software Development Lecture 29: Linked Lists. Faculty of Computer Science, Dalhousie University Heap (Free Store)
Lecture 29 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 29: Linked Lists 19-Nov-2018 Location: Chemistry 125 Time: 12:35 13:25 Instructor: Vlado Keselj Previous
More informationWrite a C program to add two Complex numbers using functions illustrating-
Scheme of valuvation Date : 29/8/2017 Marks: 40 Subject & Code : Data Structures and Applications (15CS33) Class : III A&B Name of Faculty : Ms. Saritha Time : 8:30 am to 10 am NOTE: ANSWER All FIVE QUESTIONS
More informationF.E. Sem. II. Structured Programming Approach
F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 14 [Marks : 80 Q.1(a) What do you mean by algorithm? Which points you should consider [4]
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 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 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 informationESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists
ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees Instructor: Krithika Venkataramani Semester 2, 2011-2012 1 Introduction to Linked Lists Each bead connected to the next through a
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 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 informationLinked List in Data Structure. By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra
Linked List in Data Structure By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra Linked List Like arrays, Linked List is a linear data
More informationFile I/O. Arash Rafiey. November 7, 2017
November 7, 2017 Files File is a place on disk where a group of related data is stored. Files File is a place on disk where a group of related data is stored. C provides various functions to handle files
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 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:- 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 informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationUNIT-2 Stack & Queue
UNIT-2 Stack & Queue 59 13. Stack 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 informationGuide for The C Programming Language Chapter 4
1. What is Structure? Explain the syntax of Structure declaration and initialization with example. A structure is a collection of one or more variables, possibly of different types, grouped together under
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 informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( End Semester ) SEMESTER ( Spring ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationPrinciples of C and Memory Management
COMP281 Lecture 8 Principles of C and Memory Management Dr Lei Shi Last Lecture Pointer Basics Previous Lectures Arrays, Arithmetic, Functions Last Lecture Pointer Basics Previous Lectures Arrays, Arithmetic,
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 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 informationUnderstanding Pointers
Division of Mathematics and Computer Science Maryville College Pointers and Addresses Memory is organized into a big array. Every data item occupies one or more cells. A pointer stores an address. A pointer
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 informationContent. In this chapter, you will learn:
ARRAYS & HEAP Content In this chapter, you will learn: To introduce the array data structure To understand the use of arrays To understand how to define an array, initialize an array and refer to individual
More informationMODULE 1. Introduction to Data Structures
MODULE 1 Introduction to Data Structures Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about
More informationChethan Raj C Assistant Professor Dept. of CSE
Chethan Raj C Assistant Professor Dept. of CSE Module 01: Contents 1. Data Structures. 2. Classifications (Primitive & Non Primitive). 3. Data structure Operations. 4. Review of Arrays. 5. Structures.
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur A complete C program
More informationClass Information ANNOUCEMENTS
Class Information ANNOUCEMENTS Third homework due TODAY at 11:59pm. Extension? First project has been posted, due Monday October 23, 11:59pm. Midterm exam: Friday, October 27, in class. Don t forget to
More informationPES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo
PES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo 1. (a)what is an algorithm? Draw a flowchart to print N terms of Fibonacci
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 information// CSE/CE/IT 124 JULY 2015, 2.a. algorithm to inverse the digits of a given integer. Step 1: Start Step 2: Read: NUMBER Step 3: r=0,rev=0
// CSE/CE/IT 124 JULY 2015, 2a algorithm to inverse the digits of a given integer Step 1: Start Step 2: Read: NUMBER Step 3: r=0,rev=0 Step 4: repeat until NUMBER > 0 r=number%10; rev=rev*10+r; NUMBER=NUMBER/10;
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 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 informationstruct structure_name { //Statements };
Introduction to Structure http://www.studytonight.com/c/structures-in-c.php Structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record.
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 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 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 informationP.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)
FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?
More 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 informationLecture 03 Bits, Bytes and Data Types
Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics
More informationC mini reference. 5 Binary numbers 12
C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char
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 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 informationPESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities
SOLUTION OF CONTINUOUS INTERNAL EVALUATION TEST -1 Date : 27-02 2018 Marks:60 Subject & Code : Programming in C and Data Structures- 17PCD23 Name of faculty : Dr. J Surya Prasad/Mr. Naushad Basha Saudagar
More informationProgramming Language B
Programming Language B Takako Nemoto (JAIST) 7 January Takako Nemoto (JAIST) 7 January 1 / 13 Usage of pointers #include int sato = 178; int sanaka = 175; int masaki = 179; int *isako, *hiroko;
More informationLab # 4. Files & Queues in C
Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4010: Lab # 4 Files & Queues in C Eng. Haneen El-Masry October, 2013 2 FILE * Files in C For C File I/O you need
More informationProgramming. Pointers, Multi-dimensional Arrays and Memory Management
Programming Pointers, Multi-dimensional Arrays and Memory Management Summary } Computer Memory } Pointers } Declaration, assignment, arithmetic and operators } Casting and printing pointers } Relationship
More informationMemory Allocation. General Questions
General Questions 1 Memory Allocation 1. Which header file should be included to use functions like malloc() and calloc()? A. memory.h B. stdlib.h C. string.h D. dos.h 2. What function should be used to
More informationBCSE1002: Computer Programming and Problem Solving LAB MANUAL
LABMANUAL BCSE1002: Computer Programming and Problem Solving LAB MANUAL L T P Course Type Semester Offered Academic Year 2018-2019 Slot Class Room Faculty Details: Name Website link Designation School
More informationAssignment 6. Q1. Create a database of students using structures, where in each entry of the database will have the following fields:
Assignment 6 Q1. Create a database of students using structures, where in each entry of the database will have the following fields: 1. a name, which is a string with at most 128 characters 2. their marks
More informationProcedural Programming
Exercise 6 (SS 2016) 04.07.2015 What will I learn in the 6. exercise Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Home exercise 4 (3 points) Write a program which is able to handle
More informationThis code has a bug that allows a hacker to take control of its execution and run evilfunc().
Malicious Code Insertion Example This code has a bug that allows a hacker to take control of its execution and run evilfunc(). #include // obviously it is compiler dependent // but on my system
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 informationComputer Programming Unit v
READING AND WRITING CHARACTERS We can read and write a character on screen using printf() and scanf() function but this is not applicable in all situations. In C programming language some function are
More informationC-Refresher: Session 10 Disk IO
C-Refresher: Session 10 Disk IO Arif Butt Summer 2017 I am Thankful to my student Muhammad Zubair bcsf14m029@pucit.edu.pk for preparation of these slides in accordance with my video lectures at http://www.arifbutt.me/category/c-behind-the-curtain/
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 information{C} Programming. Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics
{C Programming Part 1/2 Basics Variables, Conditions, Loops, Arrays, Pointer basics Variables A variable is a container (storage area) to hold data. Eg. Variable name int potionstrength = 95; Variable
More informationM.CS201 Programming language
Power Engineering School M.CS201 Programming language Lecture 16 Lecturer: Prof. Dr. T.Uranchimeg Agenda Opening a File Errors with open files Writing and Reading File Data Formatted File Input Direct
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 informationRicardo Rocha. Department of Computer Science Faculty of Sciences University of Porto
Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Adapted from the slides Revisões sobre Programação em C, Sérgio Crisóstomo Compilation #include int main()
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 informationSRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I
SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I Year & Sem: I B.E (CSE) & II Date of Exam: 21/02/2015 Subject Code & Name: CS6202 & Programming & Data
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays 1 What are Arrays? Arrays are our first example of structured data. Think of a book with pages numbered 1,2,...,400.
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 informationChapter 14. Dynamic Data Structures. Instructor: Öğr. Gör. Okan Vardarlı. Copyright 2004 Pearson Addison-Wesley. All rights reserved.
Chapter 14 Dynamic Data Structures Instructor: Öğr. Gör. Okan Vardarlı Copyright 2004 Pearson Addison-Wesley. All rights reserved. 12-1 Dynamic Data Structure Usually, so far, the arrays and strings we
More information