CS6202 PROGRAMING AND DATASTRUCTURE-I

Size: px
Start display at page:

Download "CS6202 PROGRAMING AND DATASTRUCTURE-I"

Transcription

1 T.J.S.ENGINEERING COLLEGE PREPARED BY BALAMURUGAN.A.G ASSISTANT PROFESSOR 16

2 UNIT 1(C PROGRAMMING FUNDAMENTALS- A REVIEW) 1. GIVE TWO EXAMPLES OF C PREPROCESSORS WITH SYNTAX #define- Substitutes a preprocessor macro Example : #define MAX_ARRAY_LENGTH 20 This directive tells the C to replace instances of MAX_ARRAY_LENGTH with 20. Use #define for constants to increase readability. #include - Inserts a particular header from another file Example : #include <stdio.h> These directives tell the C to get stdio.h from System Libraries and add the text to the current source file. The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process. In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation. All preprocessor commands begin with a hash symbol (#). It must be the first nonblank character, and for readability, a preprocessor directive should begin in the first column. The following section lists down all the important preprocessor directives Directive #define #include #undef #ifdef #ifndef #if #else #elif #endif #error #pragma Description Substitutes a preprocessor macro. Inserts a particular header from another file. Undefines a preprocessor macro. Returns true if this macro is defined. Returns true if this macro is not defined. Tests if a compile time condition is true. The alternative for #if. #else and #if in one statement. Ends preprocessor conditional. Prints error message on stderr. Issues special commands to the compiler, using a standardized method.

3 2. WHAT ARE FUNCTION POINTERS IN C? EXPLAIN WITH EXAMPLE. C allows you to return a pointer from a function. To do so, you would have to declare a function returning a pointer as in the following example int * myfunction() 3. DEFINE AN ARRAY.GIVE AN EXAMPLE Good programming practice is to declare a variable size, and store the number of elements in the array in it. size = sizeof(anarray)/sizeof(short)c also supports multi dimensional arrays (or, rather, arrays of arrays). The simplest type is a two dimensional array. Give example on call by reference The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument. To pass a value by reference, argument pointers are passed to the functions just like any other value. So accordingly you need to declare the function parameters as pointer types as in the following function swap(), which exchanges the values of the two integer variables pointed to, by their arguments. #include<stdio.h> void interchange(int *num1,int *num2) int temp; temp = *num1; *num1 = *num2; *num2 = temp; int main() int num1=50,num2=70; interchange(&num1,&num2); printf("\nnumber 1 : %d",num1); printf("\nnumber 2 : %d",num2); return(0); While passing parameter using call by address scheme, we are passing the actual address of the variable to the called function.any updates made inside the called function will modify the original copy since we are directly modifying the content of the exact memory location. 4. GIVE THE SIGNIFICANCE OF FUNCTION DECLARATION? function prototype declaration is necessary in order to provide information to the compiler about function, about return type, parameter list and function name etc. Important Points : Our program starts from main function. Each and every function is called directly or indirectly through main function Like variable we also need to declare function before using it in program. In C, declaration of function is called as prototype declaration Function declaration is also called as function prototype Below are some of the important notable things related to prototype declaration It tells name of function,return type of function and argument list related information to the compiler Prototype declaration always ends with semicolon. Parameter list is optional. Default return type is integer.

4 Syntax return_type function_name ( type arg1, type arg2... ); 5. DIFFERENTIATE BREAK AND CONTINUE STATEMENT 6. DIFFERENTIATE FUNCTION DECLARATION AND FUNCTION DEFINITION No Declaration Definition 1 Space is Not Reserved In Definition Space is Reserved 2 Identifies Data Type Some Initial Value is Assigned 3 Re-Declaration is Error Re-Definition is Error 7. WHAT IS RECURSION? LIST OUT MERITS AND DEMERITS A programming technique in which a function may call itself. Recursive programming is especially well-suited to parsing nested markup structures. Calling a function by itself is known as recursion. Any function can call any function including itself. Advantages Reduce unnecessary calling of function. Through Recursion one can Solve problems in easy way while its iterative solution is very big and complex. Disdvantages Recursive solution is always logical and it is very difficult to trace.(debug and understand). In recursive we must have an if statement somewhere to force the function to return without the recursive call being executed, otherwise the function will never return. Recursion takes a lot of stack space, usually not considerable when the program is small and running on a PC. Recursion uses more processor time.

5 8. HOW MULTI-DIMENSIONAL ARRAYS ARE STORED IN C C allows for arrays of two or more dimensions. A two-dimensional (2D) array is an array of arrays. A three-dimensional (3D) array is an array of arrays of arrays. In C programming an array can have two, three, or even ten or more dimensions. The maximum dimensions a C program can have depends on which compiler is being used. More dimensions in an array means more data be held, but also means greater difficulty in managing and understanding arrays. 9. HOW TO DECLARE A MULTIDIMENSIONAL ARRAY IN C A multidimensional array is declared using the following syntax: type array_name[d1][d2][d3][d4] [dn]; Where each d is a dimension, and dn is the size of final dimension. Examples: int table[5][5][20]; float arr[5][6][5][6][5]; In Example 1: int designates the array type integer. table is the name of our 3D array. Our array can hold 500 integer-type elements. This number is reached by multiplying the value of each dimension. In this case: 5x5x20=500. In Example 2: Array arr is a five-dimensional array. It can hold 4500 floating-point elements (5x6x5x6x5=4500). Can you see the power of declaring an array over variables? When it comes to holding multiple values in C programming, we would need to declare several variables. But a single array can hold thousands of values. Note: For the sake of simplicity, this tutorial discusses 3D arrays only. Once you grab the logic of how the 3D array works then you can handle 4D arrays and larger. Explanation of a 3D Array Let's take a closer look at a 3D array. A 3D array is essentially an array of arrays of arrays: it's an array or collection of 2D arrays, and a 2D array is an array of 1D array. It may sound a bit confusing, but don't worry. As you practice working with multidimensional arrays, you start to grasp the logic. The diagram below may help you understand: 3D Array Conceptual View 10. HOW ARRAYS ARE PASSED TO FUNCTION Passing entire array to function : Parameter Passing Scheme : Pass by Reference Pass name of array as function parameter. Name contains the base address i.e ( Address of 0th element )

6 Array values are updated in function. Values are reflected inside main function also. Graphical Flowchart : Passing Entire 1-D Array to Function in C Programming Array is passed to function Completely. Parameter Passing Method : Pass by Reference It is Also Called Pass by Address Original Copy is Passed to Function Function Body Can Modify Original Value. 11. DIFFERENTIATE STRCHR() AND STRRCHR() The functions strchr() and strrchr find the first or last occurance of a letter in a string, respectively. (The extra "r" in strrchr() stands for "reverse"--it looks starting at the end of the string and working backward.) Each function returns a pointer to the char in question, or NULL if the letter isn't found in the string. Quite straightforward. One thing you can do if you want to find the next occurance of the letter after finding the first, is call the function again with the previous return value plus one. (Remember pointer arithmetic?) Or minus one if you're looking in reverse. Don't accidentally go off the end of the string! What is a pointer to pointer A pointer to a pointer is a form of multiple indirection, or a chain of pointers. Normally, a pointer contains the address of a variable. When we define a pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value as shown below. A variable that is a pointer to a pointer must be declared as such. This is done by placing an additional asterisk in front of its name. For example, the following declaration declares a pointer to a pointer of type int int **var; When a target value is indirectly pointed to by a pointer to a pointer, accessing that value requires that the asterisk operator be applied twice 12. WHAT IS AN ARRAY OF POINTERS The interaction of pointers and arrays can be confusing but here are two fundamental statements about it: A variable declared as an array of some type acts as a pointer to that type. When used by itself, it points to the first element of the array. A pointer can be indexed like an array name.

7 13. WHAT IS A POINTER TO FUNCTION Just like you've been creating pointers to structs, strings, and arrays, you can point a pointer at a function too. The main use for this is to pass "callbacks" to other functions, or to simulate classes and objects. In this exercise we'll do some callbacks, and in the next one we'll make a simple object system. 14. GIVE EXAMPLE FOR POINTER ARITHMETIC. A pointer in c is an address, which is a numeric value. Therefore, you can perform arithmetic operations on a pointer just as you can on a numeric value. There are four arithmetic operators that can be used on pointers: ++, --, +, and - To understand pointer arithmetic, let us consider that ptr is an integer pointer which points to the address Assuming 32-bit integers, let us perform the following arithmetic operation on the pointer ptr++ After the above operation, the ptr will point to the location 1004 because each time ptr is incremented, it will point to the next integer location which is 4 bytes next to the current location. This operation will move the pointer to the next memory location without impacting the actual value at the memory location. Ifptr points to a character whose address is 1000, then the above operation will point to the location 1001 because the next character will be available at Write the features of pointers Pointers are more efficient in handling Array and Structure. Pointer allows references to function and thereby helps in passing of function as arguments to other function. It reduces length and the program execution time. It allows C to support dynamic memory management. 15. GIVE DIFFERENCES BETWEEN UNION AND STRUCTURE structure union Keyword struct defines a structure. Example structure declaration: struct s_tag int ival; float fval; char *cptr; s; Keyword union defines a union. Example union declaration: union u_tag int ival; float fval; char *cptr; u; Within a structure all members gets memory allocated and members have addresses that increase as the declarators are read left-to-right. That is, the members of a structure all begin at different offsets from the base of the structure. The offset of a particular member corresponds to the order of its declaration; the first member is at offset 0. The total size of a structure is the For a union compiler allocates the memory for the largest of all members and in a union all members have offset zero from the base, the container is big enough to hold the WIDEST member, and the alignment is appropriate for all of the types in the union. When the storage space allocated to the union contains a smaller member, the extra space

8 sum of the size of all the members or more because of appropriate alignment. between the end of the smaller member and the end of the allocated memory remains unaltered. Within a structure all members gets memory allocated; therefore any member can be retrieved at any time. One or more members of a structure can be initialized at once. While retrieving data from a union the type that is being retrieved must be the type most recently stored. It is the programmer's responsibility to keep track of which type is currently stored in a union; the results are implementation-dependent if something is stored as one type and extracted as another. A union may only be initialized with a value of the type of its first member; thus union u described above (during example declaration) can only be initialized with an integer value. 16. DEFINE SELF REFERENTIAL STRUCTURE WITH EXAMPLE A self-referential structure is one of the data structures which refer to the pointer to (points) to another structure of the same type. Forexample, a linked list is supposed to be a self- REFERENTIAL DATASTRUCTURE. THE NEXT NODE OF A NODE IS BEING POINTED, WHICH IS OF THE SAME STRUCT TYPE. 17. WHAT ARE FEATURES OF C LANGUAGE? Low level language support, Portability, Powerful, Support bits manipulation, Modular programming and use of pointers Draw the structure of C Program Linking files Global declaration section main() Declarations; Program statements; Functions definitions 18. WHAT IS THE NEED OF HEADER FILE IN C? The library functions declarations are available in the header files. To use a specific library function, we have to include the appropriate header file. Define Identifiers. Identifiers are name given to the program elements such as variable, arrays, structure, function etc. 19. WHAT ARE THE DATA TYPES SUPPORTED BY C? The data types supported by C are int float char double etc. 20. WHAT IS KEYWORD? GIVE EXAMPLE. Keywords are reserved words that have standard and predefined meaning in C. Example int, float, while, for, if

9 21. WHAT IS MEANT BY LOCAL VARIABLE? The variables which are declared inside any function are called local variables, The scope of the variable is within its own function. 22. LIST THE TYPES OF OPERATORS SUPPORTED BY C PROGRAMMING. Arithmetic operators Relational operators Logical Operators Assignment Operators Increment and Decrement Operator Conditional Operator Bitwise operator Other special operator Give the syntax of ternary operator. Variable = exp1?exp2:exp3; If the exp1 is true the exp2 will be evaluated else exp3 will be evaluated. 23. WHAT ARE THE BITWISE OPERATOR AVAILABLE IN C? & bitwise AND bitwise OR >> Right Shift << Left Shift ~ one s complement ^ bitwise XOR 24. WHAT IS THE DIFFERENCE BETWEEN ++A AND A++? ++a -> Increment the value of a by 1 before the operation a++ -> Increment the value of a by 1 after the operation Example : int a=4,x,y; x=a++; /* assigns 4 to x */ y=a /* now assigns 5 to x */ 25. WHAT ARE THE DIFFERENCES BETWEEN WHILE AND DO-WHILE LOOP? While Do while To tested Bottom tested Condition is first tested. If the condition is true It executes the block of statements atleast once then the block of statements will be executed before the condition is tested 26. WHAT IS USE OF BREAK STATEMENT? The break statement is used to terminate the loop when the keyword break is used. It can also be used to exit from the case of switch statement. 27. WHAT IS FUNCTION? Function is a group of valid program statements that performs specific tasks. The function may or may not return value. We can define function with or without parameters. What is meant by actual argument and formal arguments? The actual arguments are the arguments which are passed at the function call The formal arguments are the arguments that appear in the function definition with data type and variable name. 28. WHAT IS MEANT BY CALL BY VALUE AND CALL BY REFERENCE? Call by value calling the function by passing value to that function as parameter Call by reference calling the function by passing address of the variable as parameter

10 29. WHAT IS MEANT BY RECURSION? Recursion is a process by which a function call by itself repeatedly, until some condition has been satisfied. 30. DEFINE PREPROCESSOR. Preprocessor is not part of the compiler. It is an instruction to compiler to include header files, macro and conditional compilation in our program. Name the conditional compilation preprocessor directives. #ifdef #ifundef #if #else #elif #endif 31. WHAT IS POINTER? A pointer is a variable that contains memory address of another variable. The pointer variable can be of any type such as integer, float, character, void etc. 32. WHAT IS &, * WITH RESPECT TO POINTER? & is address operator which is used to return the address of the variable is called indirection operator 33. WHAT IS THE NEED OF NULL POINTER? A pointer that is assigned NULL is called a null pointer. It is always a good practice to assign a NULL value to a pointer variable in case you do not have exact address to be assigned. The NULL pointer is a constant with a value of zero 34. WHAT ARE THE ADVANTAGES OF USING POINTER? Pointer provides way to return multiple data items from a function Pointer enable us to access memory of a variable directly Wastages of memory space can be avoided 35. WHAT IS MEANT BY DYNAMIC MEMORY ALLOCATION AND STATIC MEMORY ALLOCATION? Allocating memory to variable, array, structure etc. during runtime of the program is called dynamic memory allocation Allocating memory to a variable, array, structure etc. during compile time of the program 36. LIST THE VARIOUS DYNAMIC MEMORY ALLOCATION FUNCTION AVAILABLE IN C. malloc() calloc() free() realloc() UNIT II(C PROGRAMMING ADVANCED FEATURES) 1. WHAT IS DIFFERENCE BETWEEN GETC() AND GETCHAR()? The getc() function reads a character from the input file referenced by file pointer. The return value is the character read, or in case of any error it returns EOF. The int getchar(void) function reads the next available character from the screen and returns it as an integer. This function reads only single character at a time.

11 2. EXPLAIN THE SYNTAX (FREAD(&MY_RECORD,SIZEOF(STRUCT REC),1,PTR_MYFILE))? fread(&my_record, sizeof(struct rec), 1, ptr_myfile) &my_record -> address of the structure to be read sizeof(struct rec) -> size of the structure 1 -> no of record to be read ptr_myfile -> read from the pointer ptr_myfile it will not work 3. GIVE APPLICATIONS IN WHICH UNIONS RATHER THAN STRUCTURES CAN BE USED? The union can be useful when we want to write memory efficient program. The union can be useful when we want to use union members one at a time 4. WILL THE FOLLOWING DECLARATION WORK. JUSTIFY YOUR ANSWER struct Student int rollno=12; float marks[]=55,60,56; char gender; ; The above declaration prompt an error. Because, initialization of members with in the structure is not allowed. 5. WHAT ARE THE STATEMENT USED FOR READING A FILE? The file I/O functions and types in the C language are straightforward and easy to understand. To make use of these functions and types you have to include the stdio library. (Like we already did in most of the tutorials). The file I/O functions in the stdio library are: fopen opens a text file. fclose closes a text file. feof detects end-of-file marker in a file. fscanf reads formatted input from a file. fprintf prints formatted output to a file. fgets reads a string from a file. fputs prints a string to a file. fgetc reads a character from a file. fputc prints a character to a file. 6. DEFINE THE NEED FOR UNION IN C? A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose. 7. DIFFERENTIATE UNION AND STRUCTURE. Structure In structure each member get separate space in memory. Union In union, the total memory space allocated is equal to the member with largest size. All other members share the same memory space.

12 We can access any member in any sequence. We can access only that variable whose value is recently stored. All the members can be initialized while declaring the variable of structure. Only first member can be initialized while declaring the variable of union. 8. LIST THE VARIOUS FILE OPENING MODES. 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. Here your program will start writing content from the beginning of the file. a Opens a text file for writing in appending mode, if it does not exist then a new file is created. Here your program will start appending content in the existing file content. r+ Opens a text file for reading and writing both. w+ Opens a text file for reading and writing both. It first truncate the file to zero length if it exists otherwise create the file if it does not exist. a+ Opens a text file for reading and writing both. It creates the file i 9. HOW STRUCTURE IS DECLARED AND STRUCTURE VARIABLE ARE ACCESSED? 10. DEFINING A STRUCTURE To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member. The format of the struct statement is as follows struct [structure tag] member definition; member definition;... member definition; [one or more structure variables]; The structure tag is optional and each member definition is a normal variable definition, such as int i; or float f; or any other valid variable definition. At the end of the structure's definition, before the final semicolon, you can specify one or more structure variables but it is optional. Here is the way you would declare the Book structure struct Books char title[50]; char author[50]; char subject[100]; int book_id; book; ACCESSING STRUCTURE MEMBERS To access any member of a structure, we use the member access operator (.). The member access operator is coded as a period between the structure variable name and the structure member that we wish to access. You would use the keyword struct to define variables of structure type 11. DIFFERENTIATE ARRAY AND STRUCTURE. Array Structure Collection of similar data items Derived data type Array elements can be accessed using array index Collection of different data items User defined data type Structure elements can be accessed using structure variable

13 12. WHAT IS AN ARRAY OF STRUCTURE AND GIVE EXAMPLE Structure is used to store the information of One particular object but if we need to store such 100 objects then Array of Structure is used. struct Bookinfo char[20] bname; int pages; int price; Book[100]; Explanation : Here Book structure is used to Store the information of one Book. In case if we need to store the Information of 100 books then Array of Structure is used. b1[0] stores the Information of 1st Book, b1[1] stores the information of 2nd Book and So on We can store the information of 100 books. 13. WHAT IS MEANT BY THE FOLLOWING TERMS? Nested structures Array of structures NESTED STRUCTURE Structure written inside another structure is called as nesting of two structures. Nested Structures are allowed in C Programming Language. We can write one Structure inside another structure as member of another structure. struct date int date; int month; int year; ; struct Employee char ename[20]; int ssn; float salary; struct date doj; emp1; ACCESSING NESTED ELEMENTS : Structure members are accessed using dot operator. date structure is nested within Employee Structure. Members of the date can be accessed using employee emp1 & doj are two structure names (Variables) 14. WHAT IS A POINTER TO STRUCTURE? GIVE EXAMPLE Pointer to Structure in C Programming Address of Pointer variable can be obtained using & operator. Address of such Structure can be assigned to the Pointer variable. Pointer Variable which stores the address of Structure must be declared as Pointer to Structure. 15. WHAT IS A POINTER TO STRUCTURE? GIVE EXAMPLE struct student_database

14 char name[10]; int roll; int marks; stud1; struct student_database *ptr; ptr = &stud1; 16. WHAT IS THE SIGNIFICANCE OF EOF? OR WRITE NOTE ON END OF FILE. Text File : A special character, whose ASCII value is 26, is inserted after the last character in the file to mark the end of file. Binary file : There is no such special character present in the binary mode files to mark the end of file. 17. EXPLAIN THE GENERAL FORMAT OF FSEEK() FUNCTION? You can perform random read and write operations using the C I/O system with the help of fseek( ), which sets the file position indicator. Its prototype is int fseek(file *fp, long int numbytes, int origin); Here, fp is a file pointer returned by a call to fopen( ), numbytes is the number of bytes from origin, which will become the new current position, and origin is one of the following macros: SEEK_SET(Beginning of file), SEEK_CUR (Current position), SEEK_END(End of file). 18. WHAT ARE THE COMMON USES OF REWIND() AND FTELL() FUNCTIONS? fseek(), ftell() and rewind() fseek() - It is used to moves the reading control to different positions using fseek function. ftell() - It tells the byte location of current position in file pointer. rewind() - It moves the control to beginning of a file. #include void main() FILE *fp; int i; clrscr(); fp = fopen("char.txt","r"); for (i=1;i<=10;i++) printf("%c : %d\n",getc(fp),ftell(fp)); fseek(fp,ftell(fp),0); if (i == 5) rewind(fp); fclose(fp); 19. HOW DOES AN APPEND MODE DIFFER FROM A WRITE MODE File Access Mode

15 While opening a file, we have to specify the mode for opening the file. Here is a list of different modes for opening any file and usage of these mode. r - Read mode - Read from a specified file which already exists. If the file doesn t exist or is not found, this operaiton fails. r+ - Read mode(+ some others) - Read from and write into an existing file. The file must exist before the operation. w - Write mode - Create new file with specified name. If the file exists, contents of the file is destroyed. w+ - Write mode(+ some others) - Write into an file. It also permits to read the data. a - Append mode - It appends content to the specified file. If the file doesn t exist, it is created first, and then contents are written into it. a+ - Append mode(+some others) - Open a file for reading and appending. 20. FSEEK Description The C library function int fseek(file *stream, long int offset, int whence)sets the file position of the stream to the given offset. Declaration Following is the declaration for fseek() function. int fseek(file *stream, long int offset, int whence) Parameters stream This is the pointer to a FILE object that identifies the stream. offset This is the number of bytes to offset from whence. whence This is the position from where offset is added. It is specified by one of the following constants Constant SEEK_SET SEEK_CUR SEEK_END Description Beginning of file Current position of the file pointer End of file Return Value This function returns zero if successful, or else it returns a non-zero value. Example The following example shows the usage of fseek() function. #include <stdio.h> int main () FILE *fp; fp = fopen("file.txt","w+"); fputs("this is tjs engginering college ", fp); fseek( fp, 7, SEEK_SET ); fputs(" C Programming Language", fp); fclose(fp); return(0);

16 Let us compile and run the above program that will create a file file.txt with the following content. Initially program creates the file and writes This is engineering college but later we had reset the write pointer at 7th position from the beginning and used puts() statement which over-write the file with the following content This is C Programming Language Now let's see the content of the above file using the following program #include <stdio.h> int main () FILE *fp; int c; fp = fopen("file.txt","r"); while(1) c = fgetc(fp); if( feof(fp) ) break; printf("%c", c); fclose(fp); return(0); 21. EXPLAIN FREAD() AND FWRITE() fread() can be used to read data from binary file. The syntax of fread() fread(address of the data item, size, number of items, file pointer) fwrite() can be used to write data into binary file. The syntax is fwrite(address of the data item, size, number of items, file pointer) What is structure in C? Structure is another user defined data type available in C. Structure is a collection of different data type items. Structures are used to represent a record Write the syntax to define structure. To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member for your program. The format of the struct statement is this: struct [structure tag] member definition; member definition;... member definition; [one or more structure variables]; 22. HOW STRUCTURE ELEMENTS CAN BE ACCESSED? To access any member of a structure, we use the member access operator (.). The member access operator is coded as a period between the structure variable name and the structure member that we wish to access. You would use struct keyword to define variables of structure type.

17 How do you initialize structure member? The following syntax will initialize structure member struct student int rno, float cgpa; ; struct s1=1,8.9; /* initializing structure member */ 23. WRITE THE SYNTAX FOR NESTED STRUCTURE If a structure is a member of another structure then the declaration is called nested structure Syntax struct marks int phy, chem, mat; ; struct student struct marks m; /* Nested Structure */ float cutoff; ; How nested structure elements can be accessed? struct marks int phy, chem, mat; ; struct student struct marks m; float cutoff; ; To access the above nested structure member struct student stud; stud.m.phy=187; stud.m.chem=192; stud.m.mat=173; stud.cutoff=stud.m.phy+stud.m.chem+stud.m.mat In the above statement, m is inner structure(marks) variable and stud is a outer structure variable(student). 24. WRITE THE SYNTAX TO DEFINE ARRAY OF STRUCTURE. struct student char rno[10], name[20]; int mark; Creating Array of Structure 25. struct student s[54]; 26. WRITE THE SYNTAX TO ALLOCATE MEMORY TO STRUCTURE.

18 struct student ; struct student *s1; To allocate memory to the structure pointer s1, s1= (student) malloc(sizeof(s1)); 27. WHAT IS UNION? GIVE EXAMPLE. A union is a special data type available in C that enables you to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multi-purpose. Example union [union tag] member definition; member definition;... member definition; [one or more union variables]; 28. WHAT ARE THE STEPS INVOLVED IN PROCESSING A FILE? Create a file stream using FILE structure Open a file using fopen() function with required mode. Perform read/write operations on file Close the file using fclose() function. 29. DIFFERENTIATE TEXT FILE AND BINARY FILE. A text file contains only textual information like alphabets, digits and special symbols. In actuality the ASCII codes of these characters are stored in text files A binary file is merely a collection of bytes. This collection might be a compiled version of a C program (say PR1.EXE), or music data stored in a wave file or a picture stored in a graphic file. 30. WHAT IS THE USE OF FGETC() AND FPUTC() FUNCTION? fgetc() int fgetc( FILE * fp ); The fgetc() function reads a character from the input file referenced by fp. The return value is the character read, or in case of any error it returns EOF fputc() int fputc( int c, FILE *fp ); The function fputc() writes the character value of the argument c to the output stream referenced by fp. It returns the written character written on success otherwise EOF if there is an error. 31. WRITE THE SIGNIFICANCE OF GETW() AND PUTW() FUNCTION. These are integer data type oriented function. putw() can be used to store integer value in the file. getw() can be used to read integer value from the file. 32. WRITE THE SYNTAX OF FPRINTF() AND FSCANF() FUNCTION. fprintf() and fscanf( ) library functions to read/write data from/to file. Sytanx of printf(): fprintf(file pointer, format specifiers, arg1,arg2..) Syntax of fscanf(): fprintf(file pointer, format specifiers, &arg1,&arg2..) 33. WRITE THE SIGNIFICANCE OF FGETS() FUNCTION. fgets() can be used to read string from a file. The syntax of fgets() is char *fgets( char *buf, int n, FILE *fp );

19 The functions fgets() reads up to n - 1 characters from the input stream referenced by fp. It copies the read string into the buffer buf, appending a null character to terminate the string. 34. HOW DO YOU FIND THE LOCATION OF FILE POINTER? The function ftell() can be used to find the location of current pointer position. This function returns an integer value. Syntax : int ftell(file pointer) 35. EXPLAIN THE C STATEMENT FSEEK ( FP, 0, SEEK_END ) ; The given C Program statement place the pointer beyond the last record in the file 36. WHAT IS THE NEED OF FFLUSH() FUNCTION IN C? If you wish to flush the contents of an output stream, use the fflush( ) function This function writes the contents of any buffered data to the file associated with fp. If you call fflush( ) with fp being null, all files opened for output are flushed. The fflush( ) function returns zero if successful; otherwise, it returns EOF UNIT III (LINEAR DATA STRUCTURES LISTS) 1. DEFINE ADT? An abstract data type (ADT) is a set of operations. Abstract data types are mathematical abstractions; nowhere in an ADT's definition is there any mention of how the set of operations is implemented. 2. WHAT IS STATIC LINKED LIST?STATE ANY TWO APPLICATIONS OF IT? Linked list is a linear data structure that consists of a sequence of nodes, each containing data field and reference field. Applications of Linked List Polynomial Manipulations Sorting using Radix Sort Should arrays or linked list be used for the following types of applications Many search operations in sorted list Array can be used. Because, searching requires less time in sorted list. Many search operations in unsorted list Linked list can be used. Because, Array requires more time for searching. 3. WHAT IS THE ADVANTAGE OF AN ADT? Modular design of data structure Easy to change the operations by merely changing the routines that perform the ADT operations 4. WHAT ARE ABSTRACT DATA TYPE? An abstract data type (ADT) is a set of operations. Abstract data types are mathematical abstractions; nowhere in an ADT's definition is there any mention of how the set of operations is implemented. 5. WHAT IS CIRCULAR LINKED LIST? In a linked list, the pointer of the last node points to the first node then the list is said to be Circularly linked list. 6. WHAT ARE THE ADVANTAGES OF LINKED LIST OVER ARRAYS? List of advantages : Linked List is Dynamic data Structure. Linked List can grow and shrink during run time. Insertion and Deletion Operations are Easier Efficient Memory Utilization,i.e no need to pre-allocate memory Faster Access time,can be expanded in constant time without memory overhead

20 Linear Data Structures such as Stack,Queue can be easily implemetedusing Linked list 7. WHAT ARE THE OPERATIONS OF ADT? OR WHAT ARE THE OPERATIONS PERFORMED ON LIST ADT? Insertion Deletion Traversal Sorting Searching Merging 8. LIST OUT THE AREAS IN WHICH DATA STRUCTURES ARE APPLIED EXTENSIVELY 1.compiler design 2.operating system 3.database management system 4.statistical analysis package 5.numerical analysis 6.graphs 7.artificial intelligence 8.simulation 9. WHAT ARE THE DIFFERENT TYPES OF DATA STRUCTURES? OR DEFINE NON- LINEAR DATA STRUCTURE There are two types of data structure Linear data structure - A data structure is said to be linear, if its elements form a sequence. Non-linear data structure - A data structure is said to be Non-linear, if its elements are not in sequence. 10. DISTINGUISH BETWEEN LINEAR AND NON-LINEAR DATA STRUCTURES Main difference between linear and nonlinear data structures lie in the way they organize data elements. In linear data structures, data elements are organized sequentially and therefore they are easy to implement in the computer s memory. In nonlinear data structures, a data element can be attached to several other data elements to represent specific relationships that exist among them. Due to this nonlinear structure, they might be difficult to be implemented in computer s linear memory compared to implementing linear data structures. Selecting one data structure type over the other should be done carefully by considering the relationship among the data elements that needs to be stored. 11. MENTION THE APPLICATIONS OF LIST. OR WHAT ARE APPLICATIONS OF LIST DATA STRUCTURE? To perform polynomial manipulation Radix sort Multilist 12. WHAT IS A LINKED LIST? Linked list is a linear data structure. It consists of sequence of nodes, each containing data field and address field. It is a self referential data type, because it contains a link to another data of same type. What are the types of Linked list? Linear Linked List Singly Doubly Circularly Linked List

21 Singly Doubly 13. WRITE THE SIGNIFICANCE OF HEAD NODE. OR WHAT IS THE NEED FOR THE HEADER? Head node of the list is the first node of the list. It stores number of elements in the list. It always point to the first element in the list 14. DEFINE SINGLE LINKED LIST. Singly Linked Lists are a type of data structure. It is a type of list. In asingly linked list each node in the list stores the contents of the node and a pointer or reference to the next node in the list. It does not store any pointer or reference to the previous node. 15. DEFINE DOUBLY LINKED LIST 16. a doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous and to the next node in the sequence of nodes. 17. DEFINE CIRCULAR DOUBLY LINKED LIST? In a circularly linked list, all nodes are linked in a continuous circle, without using null. For lists with a front and a back (such as a queue), one stores a reference to the last node in the list. The next node after the last node is the first node. 18. WHAT IS THE ADVANTAGE OF DOUBLE LINKED LIST OVER SINGLE LINKED LIST IMPLEMENTATION? We can traverse list forward and backward We can insert and delete anywhere in the list. Insertion and deletion is easy 19. LIST OUT THE ADVANTAGE OF CIRCULAR LINKED LIST. OR WHAT IS CIRCULARLY LINKED LIST? WRITE ITS ADVANTAGES It allows to traverse the list starting at any point It allows quick access to the first and last element It allows to traverse the list in either direction 20. WHAT IS DATA STRUCTURE? GIVE EXAMPLE Data structure is a way of organizing data. List, Stack, Queue, Linked List are some of the data structure. 21. WHAT IS LIST? List is a linear collection of data items. The list can be implemented using array, linked list and cursor 22. LIST OUT THE DISADVANTAGES OF USING A LINKED LIST DRAWBACKS / DISADVANTAGES OF LINKED LIST

22 WASTAGE OF MEMORY Pointer Requires extra memory for storage. Suppose we want to store 3 integer data items then we have to allocate memory in case of array Memory Required in Array = 3 Integer * Size = 3 * 2 bytes = 6 bytes in case of array Memory Required in LL = 3 Integer * Size of Node = 3 * Size of Node Structure = 3 * Size(data + address pointer) = 3 * (2 bytes + x bytes) = 6 bytes + 3x bytes *x is size of complete node structure it may vary NO RANDOM ACCESS In array we can access nth element easily just by using a[n]. In Linked list no random access is given to user, we have to access each node sequentially. Suppose we have to access nth node then we have to traverse linked list n times. Suppose Element is present at the starting location then We can access element in first Attempt Suppose Element is present at the Last location then We can access element in last Attempt 3. TIME COMPLEXITY Array can be randomly accessed, while the Linked list cannot be accessed Randomly Individual nodes are not stored in the contiguous memory Locations. Access time for Individual Element is O(n) whereas in Array it is O(1). Reverse Traversing is difficult In case if we are using singly linked list then it is very difficult to traverse linked list from end. If using doubly linked list then though it becomes easier to traverse from end but still it increases again storage space for back pointer. HEAP SPACE RESTRICTION Whenever memory is dynamically allocated, It utilizes memory from heap. Memory is allocated to Linked List at run time if and only if there is space available in heap. If there is insufficient space in heap then it won t create any memory. 23. STATE THE DIFFERENCE BETWEEN ARRAYS AND LINKED LISTS? Array Linked List Collection of items of similar types Chain of nodes. Each node has at least two members. Static memory allocation Dynamic memory allocation Wastage of memory space No wastage of memory space Insertion and deletion takes more time Insertion and deletion takes less time 24. WHAT ARE THE DISADVANTAGES OF USING ARRAY IN LIST IMPLEMENTATION? The arrays are fixed size Elements are stored in continuous memory location which may not be available always Adding and removing elements are difficult

23 25. DRAW THE STRUCTURE OF LINKED LIST. 26. DRAW THE STRUCTURE OF DOUBLY LINKED LIST 27. DRAW THE STRUCTURE OF CIRCULARLY LINKED LIST. UNIT IV (LINEAR DATA STRUCTURES STACK & QUEUES) 1. WRITE THE SYNTAX OF CALLOC()AND REALLOC() AND MENTION ITS APPLICATION IN LINKED LIST.? calloc( ) Allocates sufficient memory for an array of num objects of size size. Syntax of calloc() calloc(number of Objects, Size); realloc() Reallocates the block of memory. The syntax of realloc() realloc(void *ptr, size_t size); Application in Linked list realloc( ) changes the size of the previously allocated memory pointed to by ptr to that specified by size The calloc() can be used to allocate memory to node in the linked list. The realloc() can be used to reallocates the block memory that was allocated to the node. 2. DEFINE DOUBLE ENDED QUEUE? It is a linear data structure that implements queue in which elements can be inserted and deleted at both ends(front and rear) of the queue. 3. LIST THE APPLICATIONS OF A QUEUE There are several algorithms that use queues to give efficient running times When jobs are sent to a printer, in order of arrival, a queue. Customers at ticket counters Queuing theory in mathematics 4. GIVE THE APPLICATIONS OF STACK? Evaluating and postfix expression Conversion from infix to postfix Recursive function call Balancing symbols in the expression 5. WHAT IS DOUBLY ENDED QUEUE? It is a linear data structure that implements queue in which elements can be inserted and deleted at both ends(front and rear) of the queue. 6. DEFINE A STACK A stack is a list with the restriction that inserts and deletes can be performed in only one position, namely the end of the list called the top

24 7. LIST OUT THE BASIC OPERATIONS THAT CAN BE PERFORMED ON A STACK OR WHAT ARE THE OPERATIONS PERFORMED ON STACK? The fundamental operations on a stack are push, which is equivalent to an insert, and pop, which deletes the most recently inserted element. The most recently inserted element can be examined prior to performing a pop by use of the top routine 8. STATE THE ADVANTAGES AND DISADVANTAGES OF USING INFIX NOTATIONS AND POSTFIX NOTATIONS. Infix notation: Advantages: Commonality of expression. We don't need separation symbols for numbers, since symbols for functions effectively do this. We'd don't have to have a clear idea about the arity of functional symbols before using them. Disadvantages: Lack of ability to use the rule of replacement mechanically. Possible, and arguably actual, ambiguous expressions. We need an "order of operations", or something similar, to prevent ambiguity. It takes time and effort to learn about the infinity of arithmetical expressions, in the sense that seeing that from any arithmetical expression and closure, we can have arithmetical expressions beyond that of any given length. Posfix notation: Advantages: Can mechanically use the rule of replacement. So far as I can tell, it comes as consonant with how we practically use mathematics in everyday life, e. g. when we buy something with say x dollars which costs y dollars, we then figure out how much x and y differ by. Or if we start off walking at time j and finish walking at time i without a stopwatch, then we figure out how long we've walked for by figuring out how much j and i differ by. We can quickly learn about the infinity of arithmetical expressions. Disadvantages: For clarity, we require separation symbols or spaces using Hindu-Arabic numerals. Not often used by mathematical and logical writers at present. To keep things clear, it comes as important to recognize the arity of functional symbols before we use them. 9. STATE THE DIFFERENCE BETWEEN STACKS AND LINKED LISTS Stack and link list are both are data structures. Stack is liner type data structure, i.e. they are arranging in liner manner. In stack whatever is stored first it comes out last. It works in LIFO manner(last in first out). In stack you can t add element in between. They are like a stack of coins, i.e. if you want to take the last coin, then all the upper coins have to be removed one by one. Link list is not a liner data structure. Here you can access any element or add any element in between. There is no LIFO of LILO manner (last in last out). In Link list you basically use to pointers, one to store the value of the variable and other to store the address of the next node(link list single element known as node).as the next link list address is store in the second node, there is no restriction in adding a new link list element in between. Use: Linked lists provide very fast insertion or deletion of a list member. As each linked list contains a pointer to the next member in the list. Whereas there is disadvantage if you want to perform random accesses it has to go through all the lists. 10. WHAT ARE THE APPLICATIONS OF STACK?

25 Evaluating and postfix expression Conversion from infix to postfix Recursive function call Balancing symbols in the expression 11. DEFINE A QUEUE Queue is a linear data structure in which item can be inserted at one end (rear) and remove from one end(front) 12. WHAT ARE THE TYPES OF QUEUES? Different types of queues: 4 A queue is a type of abstract data type that can be implemented as a linear or circular list. 4 A queue has a front and a rear. Queue can be of four types: Simple Queue Circular Queue Priority Queue Dequeue (Double Ended queue) SIMPLE QUEUE: In Simple queue Insertion occurs at the rear of the list, and deletion occurs at the front of the list. CIRCULAR QUEUE : A circular queue is a queue in which all nodes are treated as circular such that the first node follows the last node. PRIORITY QUEUE: A priority queue is a queue that contains items that have some preset priority. When an element has to be removed from a priority queue, the item with the highest priority is removed first DEQUEUE (DOUBLE ENDED QUEUE): In dequeue(double ended queue) Insertion and Deletion occur at both the ends i.e. front and rear of the queue. 13. DEFINE CIRCULAR QUEUE OR WHAT IS MEANT BY CIRCULAR QUEUE. In the circular queue, the first element is stored immediately after the last element. If the last location is occupied, the new element is inserted at the first memory location of the queue 14. WHAT ARE METHODS USED TO IMPLEMENT STACK? Array based Linked List based

26 15. WRITE THE PROCEDURE TO INSERT ITEM INTO STACK. Check the stack is full or not If the stack is full, we cannot insert any item into the stack Increment the top pointer by 1 Push the item into the top of the stack Write the procedure to remove item from stack Check whether stack is empty or not If the stack is empty, we cannot remove item from the stack Decrement the top pointer by WRITE THE PROCEDURE TO EVALUATE POSTFIX EXPRESSION USING STACK Read the character one by one do steps b & c till the end of the expression If the current character is an operand then push it onto stack If the current character is an operator Pop an element and store as operator2 Pop an element and store as operator 1 Evaluate the expression Push the result into stack End 17. WHAT IS THE USE OF STACK IN RECURSIVE FUNCTION CALL? When there is a recursive function call, all the important information such as variable names, return address, arguments are stored using stack All the information are saved in the place called stack frame A recursive function call pushes stack frame into stack When the return address is reached, the stack frame is popped out the stack 18. CONVERT THE EXPRESSION A + B * C + ( D * E + F ) * G INTO POSTFIX a + b * c + ( d * e + f ) * g a + b * c + (de*+f)*g a+b*c+(de*f+)*g a+bc*+(de*f+)*g a+bc*+(de*f+g*) (abc*+)+(de*f+g*) Answer : a b c * + d e * f + g * CONVERT THE EXPRESSION A + B * C + ( D * E + F ) * G INTO PREFIX 20. a + b * c + ( d * e + f ) * g a + b * c + (*de+f)*g a+b*c+(+*def)*g a+*bc+(+*def)*g a+(*bc)+(*+*defg) (+a*bc) +(*+*defg) Answer : ++a*bc*+*defg 21. WRITE A PROCEDURE TO INSERT ITEM INTO QUEUE. Check whether queue is full or not If queue is full, we cannot insert item Increment the rear pointer by 1 Insert the item into the rear pointer position 22. WRITE A PROCEDURE TO REMOVE ITEM FROM THE QUEUE. Check whether queue is empty or not

27 If the queue is empty, no item in the queue Remove the item from the front pointer position Increment the front pointer by WHAT ARE THE OPERATIONS PERFORMED ON QUEUE? They are two operations usually performed on queue. They are Enqueue this operation insert new item into queue Dequeue - this operation remove an item from the queue 24. LIST OUT THE APPLICATIONS OF QUEUE. There are several algorithms that use queues to give efficient running times When jobs are sent to a printer, in order of arrival, a queue. Customers at ticket counters Queuing theory in mathematics 25. WRITE NOTE ON DOUBLE ENDED QUEUE. It is a linear data structure that implements First In First Out method, in which the elements can be inserted and deleted at both ends(front and rear) of queue 26. WHAT ARE THE OPERATIONS PERFORMED ON DOUBLE ENDED QUEUE? Insert an item at front end Insert an item at rear end Delete an item from the front end Delete an item from the rear end Traverse through the list 27. WHAT ARE THE APPLICATIONS OF DOUBLE ENDED QUEUE? Palindrome checking A Steal Job scheduling problem Undo Redo operation in Software applications UNIT V (SORTING, SEARCHING AND HASH TECHNIQUES) 1. WHAT IS MEANT BY INTERNAL AND EXTERNAL SORTING?GIVE FOUR EXAMPLES OF EACH TYPE? Internal sorting All the data to be sorted is stored in Main memory during sorting. Example : Bubble sort, Insertion Sort, Merge sort External Sorting Data is stored outside the main memory such as secondary memory devices during sorting. Example : Two Way Merge sort, Replacement Selection sort 2. STATE THE APPLICATIONS OF LINEAR AND BINARY SEARCH TECHNIQUES Linear search can be applicable when we have less data Binary search can be applicable when we have huge amount of data 3. WHAT IS THE TIME COMPLEXITY OF BINARY SEARCH? The running time of binary search is 1+logn 4. LIST SORTING ALGORITHM WHICH USES LOGARITHMIC TIME COMPLEXITY. Shell sort, heap sort, merge sort, quick sort Define extendible hashing. It is one of the method of hashing in which it performs all the insertion, deletion and searching process in a fast manner on large databases. It is more suitable when we have huge amount of data. 5. DIFFERENTIATE INTERNAL AND EXTERNAL SORTING. Internal sorting

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : I / II Section : CSE - 1 & 2 Subject Code : CS6202 Subject Name : Programming and Data Structures-I Degree & Branch : B.E C.S.E. 2 MARK

More information

V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester. Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2

V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester. Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2 V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2 CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1.

More information

CS PROGRAMMING & ATA STRUCTURES I. UNIT I Part - A

CS PROGRAMMING & ATA STRUCTURES I. UNIT I Part - A CS6202 - PROGRAMMING & ATA STRUCTURES I Question Bank UNIT I Part - A 1. What are Keywords? 2. What is the difference between if and while statement? 3. What is the difference between while loop and do

More information

DEPARTMENT 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 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 information

Reg. No. : Question Paper Code : 27157

Reg. No. : Question Paper Code : 27157 WK 3 Reg. No. : Question Paper Code : 27157 B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2015. Time : Three hours Second Semester Computer Science and Engineering CS 6202 PROGRAMMING AND DATA STRUCTURES

More information

Advanced C Programming and Introduction to Data Structures

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

More information

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3 UNIT 3 LINEAR DATA STRUCTURES 1. Define Data Structures Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between

More information

PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 PROGRAMMAZIONE I A.A. 2017/2018 INPUT/OUTPUT INPUT AND OUTPUT Programs must be able to write data to files or to physical output devices such as displays or printers, and to read in data from files or

More information

CSCI 171 Chapter Outlines

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

More information

CS PROGRAMMING & DATA STRUCTURES. UNIT I Part - A. 2. What is the difference between if and while statement?

CS 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 information

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS

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 information

Computer Programming Unit v

Computer 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 information

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

1 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 information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (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 information

MODULE 5: Pointers, Preprocessor Directives and Data Structures

MODULE 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 information

Code No: R Set No. 1

Code 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 information

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING SIDDARTHA INSTITUTE OF SCIENCE AND TECHNOLOGY:: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : PROGRAMMING FOR PROBLEM SOLVING (18CS0501) Course & Branch

More information

Unit 6 Files. putchar(ch); ch = getc (fp); //Reads single character from file and advances position to next character

Unit 6 Files. putchar(ch); ch = getc (fp); //Reads single character from file and advances position to next character 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e Storage of data in variables and arrays is temporary such data is lost when a program terminates. Files are used for permanent retention of data. Computers store files on secondary

More information

DEEPIKA KAMBOJ UNIT 2. What is Stack?

DEEPIKA 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 information

Mode Meaning r Opens the file for reading. If the file doesn't exist, fopen() returns NULL.

Mode Meaning r Opens the file for reading. If the file doesn't exist, fopen() returns NULL. Files Files enable permanent storage of information C performs all input and output, including disk files, by means of streams Stream oriented data files are divided into two categories Formatted data

More information

UNIT IV-2. The I/O library functions can be classified into two broad categories:

UNIT IV-2. The I/O library functions can be classified into two broad categories: UNIT IV-2 6.0 INTRODUCTION Reading, processing and writing of data are the three essential functions of a computer program. Most programs take some data as input and display the processed data, often known

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

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

More information

Problem Solving and 'C' Programming

Problem 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 information

Model Viva Questions for Programming in C lab

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

More information

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

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

More information

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

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

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions

More information

CSI 402 Lecture 2 Working with Files (Text and Binary)

CSI 402 Lecture 2 Working with Files (Text and Binary) CSI 402 Lecture 2 Working with Files (Text and Binary) 1 / 30 AQuickReviewofStandardI/O Recall that #include allows use of printf and scanf functions Example: int i; scanf("%d", &i); printf("value

More information

MARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100

MARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100 FINAL EXAMINATION INTRODUCTION TO ALGORITHMS AND PROGRAMMING II 03-60-141-01 U N I V E R S I T Y O F W I N D S O R S C H O O L O F C O M P U T E R S C I E N C E Winter 2014 Last Name: First Name: Student

More information

CP2 Revision. theme: dynamic datatypes & data structures

CP2 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 information

Programming and Data Structure Solved. MCQs- Part 2

Programming 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 information

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

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

FORTH 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 information

Cpt S 122 Data Structures. Data Structures

Cpt 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 information

Contents. Preface. Introduction. Introduction to C Programming

Contents. Preface. Introduction. Introduction to C Programming c11fptoc.fm Page vii Saturday, March 23, 2013 4:15 PM Preface xv 1 Introduction 1 1.1 1.2 1.3 1.4 1.5 Introduction The C Programming Language C Standard Library C++ and Other C-Based Languages Typical

More information

PESIT Bangalore South Campus Department of MCA Course Information for

PESIT Bangalore South Campus Department of MCA Course Information for 1. GENERAL INFORMATION: PESIT Bangalore South Campus Department of MCA Course Information for Data Structures Using C(13MCA21) Academic Year: 2015 Semester: II Title Code Duration (hrs) Lectures 48 Hrs

More information

Preprocessing directives are lines in your program that start with `#'. The `#' is followed by an identifier that is the directive name.

Preprocessing directives are lines in your program that start with `#'. The `#' is followed by an identifier that is the directive name. Unit-III Preprocessor: The C preprocessor is a macro processor that is used automatically by the C compiler to transform your program before actual compilation. It is called a macro processor because it

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

Linked List. April 2, 2007 Programming and Data Structure 1

Linked 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 information

Data Structure Series

Data Structure Series Data Structure Series This series is actually something I started back when I was part of the Sweet.Oblivion staff, but then some things happened and I was no longer able to complete it. So now, after

More information

SAURASHTRA UNIVERSITY

SAURASHTRA 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 information

Unit IV & V Previous Papers 1 mark Answers

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

More information

File Handling. Reference:

File Handling. Reference: File Handling Reference: http://www.tutorialspoint.com/c_standard_library/ Array argument return int * getrandom( ) static int r[10]; int i; /* set the seed */ srand( (unsigned)time( NULL ) ); for ( i

More information

Subject: Fundamental of Computer Programming 2068

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

1 P age DS & OOPS / UNIT II

1 P age DS & OOPS / UNIT II UNIT II Stacks: Definition operations - applications of stack. Queues: Definition - operations Priority queues - De que Applications of queue. Linked List: Singly Linked List, Doubly Linked List, Circular

More information

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis p. 5 Statement Constructs p. 5 Pseudocode Example p.

More information

Systems Programming. 08. Standard I/O Library. Alexander Holupirek

Systems Programming. 08. Standard I/O Library. Alexander Holupirek Systems Programming 08. Standard I/O Library Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Last lecture:

More information

C-Refresher: Session 10 Disk IO

C-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 information

CMPE-013/L. File I/O. File Processing. Gabriel Hugh Elkaim Winter File Processing. Files and Streams. Outline.

CMPE-013/L. File I/O. File Processing. Gabriel Hugh Elkaim Winter File Processing. Files and Streams. Outline. CMPE-013/L Outline File Processing File I/O Gabriel Hugh Elkaim Winter 2014 Files and Streams Open and Close Files Read and Write Sequential Files Read and Write Random Access Files Read and Write Random

More information

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS The Waite Group's New Primer Plus Second Edition Mitchell Waite and Stephen Prata SAMS PUBLISHING A Division of Prentice Hall Computer Publishing 11711 North College, Carmel, Indiana 46032 USA Contents

More information

ENG120. Misc. Topics

ENG120. Misc. Topics ENG120 Misc. Topics Topics Files in C Using Command-Line Arguments Typecasting Working with Multiple source files Conditional Operator 2 Files and Streams C views each file as a sequence of bytes File

More information

Writing 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 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 information

Programming Fundamentals

Programming Fundamentals Programming Fundamentals Day 4 1 Session Plan Searching & Sorting Sorting Selection Sort Insertion Sort Bubble Sort Searching Linear Search Binary Search File Handling Functions Copyright 2004, 2 2 Sorting

More information

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions.

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions. 1 of 22 8/4/2018, 4:03 PM Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008

More information

Course Title: C Programming Full Marks: Course no: CSC110 Pass Marks: Nature of course: Theory + Lab Credit hours: 3

Course Title: C Programming Full Marks: Course no: CSC110 Pass Marks: Nature of course: Theory + Lab Credit hours: 3 Detailed Syllabus : Course Title: C Programming Full Marks: 60+20+20 Course no: CSC110 Pass Marks: 24+8+8 Nature of course: Theory + Lab Credit hours: 3 Course Description: This course covers the concepts

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

FORTH 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 information

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Cpt S 122 Data Structures. Course Review Midterm Exam # 1 Cpt S 122 Data Structures Course Review Midterm Exam # 1 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 1 When: Friday (09/28) 12:10-1pm Where:

More information

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060

Files and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060 CS 2060 Files and Streams Files are used for long-term storage of data (on a hard drive rather than in memory). Files and Streams Files are used for long-term storage of data (on a hard drive rather than

More information

Lecture 9: File Processing. Quazi Rahman

Lecture 9: File Processing. Quazi Rahman 60-141 Lecture 9: File Processing Quazi Rahman 1 Outlines Files Data Hierarchy File Operations Types of File Accessing Files 2 FILES Storage of data in variables, arrays or in any other data structures,

More information

Standard C Library Functions

Standard C Library Functions Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 13 si 14: Unix interface for working with files. Cristina Nita-Rotaru Lecture 13/Fall 2013 1 Working with Files (I/O) File system: specifies how the information is organized

More information

Quick review of previous lecture Ch6 Structure Ch7 I/O. EECS2031 Software Tools. C - Structures, Unions, Enums & Typedef (K&R Ch.

Quick review of previous lecture Ch6 Structure Ch7 I/O. EECS2031 Software Tools. C - Structures, Unions, Enums & Typedef (K&R Ch. 1 Quick review of previous lecture Ch6 Structure Ch7 I/O EECS2031 Software Tools C - Structures, Unions, Enums & Typedef (K&R Ch.6) Structures Basics: Declaration and assignment Structures and functions

More information

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C Sample Test Paper-I Marks : 25 Time:1 Hrs. Q1. Attempt any THREE 09 Marks a) State four relational operators with meaning. b) State the use of break statement. c) What is constant? Give any two examples.

More information

CSci 4061 Introduction to Operating Systems. Input/Output: High-level

CSci 4061 Introduction to Operating Systems. Input/Output: High-level CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device

More information

KLiC C Programming. (KLiC Certificate in C Programming)

KLiC C Programming. (KLiC Certificate in C Programming) KLiC C Programming (KLiC Certificate in C Programming) Turbo C Skills: The C Character Set, Constants, Variables and Keywords, Types of C Constants, Types of C Variables, C Keywords, Receiving Input, Integer

More information

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM

More information

CSI 402 Lecture 2 (More on Files) 2 1 / 20

CSI 402 Lecture 2 (More on Files) 2 1 / 20 CSI 402 Lecture 2 (More on Files) 2 1 / 20 Files A Quick Review Type for file variables: FILE * File operations use functions from stdio.h. Functions fopen and fclose for opening and closing files. Functions

More information

Pointers and File Handling

Pointers 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 information

File I/O. Arash Rafiey. November 7, 2017

File 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 information

Types of Data Structures

Types of Data Structures DATA STRUCTURES material prepared by: MUKESH BOHRA Follow me on FB : http://www.facebook.com/mukesh.sirji4u The logical or mathematical model of data is called a data structure. In other words, a data

More information

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

M1-R4: Programing and Problem Solving using C (JULY 2018) M1-R4: Programing and Problem Solving using C (JULY 2018) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter

More information

Questions Bank. 14) State any four advantages of using flow-chart

Questions Bank. 14) State any four advantages of using flow-chart Questions Bank Sub:PIC(22228) Course Code:-EJ-2I ----------------------------------------------------------------------------------------------- Chapter:-1 (Overview of C Programming)(10 Marks) 1) State

More information

8. Structures, File I/O, Recursion. 18 th October IIT Kanpur

8. Structures, File I/O, Recursion. 18 th October IIT Kanpur 8. Structures, File I/O, Recursion 18 th October IIT Kanpur C Course, Programming club, Fall 2008 1 Basic of Structures Definition: A collection of one or more different variables with the same handle

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

File I/O. Preprocessor Macros

File I/O. Preprocessor Macros Computer Programming File I/O. Preprocessor Macros Marius Minea marius@cs.upt.ro 4 December 2017 Files and streams A file is a data resource on persistent storage (e.g. disk). File contents are typically

More information

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu. 7CA00 PROBLEM SOLVING AND PROGRAMMING Academic Year : 08-09 Programme : P.G-MCA Question Bank Year / Semester : I/I Course Coordinator: A.HEMA Course Objectives. To understand the various problem solving

More information

Postfix (and prefix) notation

Postfix (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 information

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C 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 information

Introduction to C Language (M3-R )

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

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Arrays and Linked Lists

Arrays and Linked Lists Arrays and Linked Lists Abstract Data Types Stacks Queues Priority Queues and Deques John Edgar 2 And Stacks Reverse Polish Notation (RPN) Also known as postfix notation A mathematical notation Where every

More information

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

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 information

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

End-Term Examination Second Semester [MCA] MAY-JUNE 2006 (Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.

More information

17CS33:Data Structures Using C QUESTION BANK

17CS33:Data Structures Using C QUESTION BANK 17CS33:Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C Learn : Usage of structures, unions - a conventional tool for handling a group of logically

More information

CSI 402 Systems Programming LECTURE 4 FILES AND FILE OPERATIONS

CSI 402 Systems Programming LECTURE 4 FILES AND FILE OPERATIONS CSI 402 Systems Programming LECTURE 4 FILES AND FILE OPERATIONS A mini Quiz 2 Consider the following struct definition struct name{ int a; float b; }; Then somewhere in main() struct name *ptr,p; ptr=&p;

More information

EM108 Software Development for Engineers

EM108 Software Development for Engineers EE108 Section 4 Files page 1 of 14 EM108 Software Development for Engineers Section 4 - Files 1) Introduction 2) Operations with Files 3) Opening Files 4) Input/Output Operations 5) Other Operations 6)

More information

SAE1A Programming in C. Unit : I - V

SAE1A 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA 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 information

Department of Computer Science and Technology

Department of Computer Science and Technology UNIT : Stack & Queue Short Questions 1 1 1 1 1 1 1 1 20) 2 What is the difference between Data and Information? Define Data, Information, and Data Structure. List the primitive data structure. List the

More information

Actually, C provides another type of variable which allows us to do just that. These are called dynamic variables.

Actually, 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 information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK III SEMESTER CS8391-Data Structures Regulation 2017 Academic Year 2018 19(odd Semester)

More information

UNIX System Programming

UNIX System Programming File I/O 경희대학교컴퓨터공학과 조진성 UNIX System Programming File in UNIX n Unified interface for all I/Os in UNIX ü Regular(normal) files in file system ü Special files for devices terminal, keyboard, mouse, tape,

More information

EL6483: Brief Overview of C Programming Language

EL6483: Brief Overview of C Programming Language EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring 2016 1 / 30 Preprocessor macros, Syntax for comments Macro definitions

More information

Lists, Stacks, and Queues. (Lists, Stacks, and Queues ) Data Structures and Programming Spring / 50

Lists, Stacks, and Queues. (Lists, Stacks, and Queues ) Data Structures and Programming Spring / 50 Lists, Stacks, and Queues (Lists, Stacks, and Queues ) Data Structures and Programming Spring 2016 1 / 50 Abstract Data Types (ADT) Data type a set of objects + a set of operations Example: integer set

More information

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files CS113: Lecture 7 Topics: The C Preprocessor I/O, Streams, Files 1 Remember the name: Pre-processor Most commonly used features: #include, #define. Think of the preprocessor as processing the file so as

More information

Draw a diagram of an empty circular queue and describe it to the reader.

Draw a diagram of an empty circular queue and describe it to the reader. 1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 1 1983/84 COSC1020/30 Tests >>> The following was given to students. >>> Students can have a good idea of test questions by examining and trying the

More information

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions.

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions. UNIT-V Unit-5 File Streams Formatted I/O Preprocessor Directives Printf Scanf A file represents a sequence of bytes on the disk where a group of related data is stored. File is created for permanent storage

More information

DATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

DATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. DATA STRUCUTRES A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. An algorithm, which is a finite sequence of instructions, each of which

More information