C program question bank




















Levels are nothing but complexity and toughness of programming questions. Therefore all the c programming questions are also separated by the categories. This is a high-level section for legendary programmers or thinkers, this section can help you to become a pro programmer. Write a C program to find the factorial of a number using while loop, where the number n is entered by the user.

Write a C program to plot a Pascal's triangle. Write a calculator program in C language to do simple commercial calculator operation like addition, subtraction, multiplication and division using switch statement.

Write a C Program to display prime numbers within a given range. Write a C program to display Armstrong numbers within given range. Module 3. Write a C Program to concatenate two strings without using built-in function strcat. Write with syntax and example to initialize 2 dimensional arrays.

Write a C Program to transpose a matrix. Write a C Program to find greatest number from two dimensional array. Write a C program to implement Selection Sort. Write a C program to sort strings using Bubble Sort. Write a C program to search a name in a sorted list of name using binary search.

Write a C program to check whether a string with spaces is palindrome or not without using built-in function. Module 4. Storage class is important, 2. Pointers will be covered up to 4th Module. Write a function to find LCM of two numbers. Write a function to accept an array of intergers and to sort it using selection sort method.

For factorial use recursion. A generic pointer is a pointer variable that has void as its data type. The void pointer or generic pointer is a special type of pointer that can point to variables of any data type. It is declared like a normal pointer variable but using the void keyword as the pointer's data type.

Define pointer to pointer. The pointers in turn point to data or even to other pointers. Write the drawbacks of pointers. Pointers are very useful in C, they are not free from limitations.

If used incorrectly, pointers can lead to bugs that are difficult to unearth. Example: If you use a pointer to read a memory location but that pointer is pointing to an incorrect location, then you may end up reading a wrong value. An erroneous input always leads to an erroneous output. Thus however efficient our program code may be, the output will always be disastrous. What does the following declaration tells compiler? How to passing an entire one-dimensional array to a function? While passing arrays as arguments to the function, only the name of the array is passed ,i.

Differentiate between an array and pointer? The difference between arrays and pointers are as follows. Array Pointer Array allocates space automatically Pointer is explicitly assigned to point to an 1 allocated space. It can be resized using realloc. Pointers can be reassigned. Size of array name gives the number of Size of pointer name returns the number of 4 bytes occupied by the array. Write a C program to swap two numbers.

Before swapping. Demonstrate use of reference operator in C program. Explain in detail about recursion with example. Function is called within the same function Write factorial program 2.

Explain in detail about pointers with example. NULL Pointer 3. Write a C program to compute sine series. Design a scientific calculator using built-in functions in C. Explain detail about pointers and arrays. A pointer variable takes different addresses as value whereas, in case of array it is fixed.

Relation between Arrays and Pointers 6. Write a C program to access array elements using Pointers. Write a program in C to find the number of , , 50, 20, 10, 5, 2, 1 rupee notes in a given amount. Write a C program to sort a list in alphabetic order using pointers. Define structure. Structure is a user defined data type in C. It is somewhat similar to an array. The only difference is that array is used to store collection of similar data types while structure can store collection of any type of data.

A structure is therefore a collection of variables under a single name. Define self referential structure. A self referential structure is one of the data structures which refer to the pointer to another structure of the same type.

That is, a self referential structure, in addition to other data, contains a pointer to a data that is of the same type as that of the structure. A self referential structure is used to create data structures like linked lists, stacks, etc.

Define dynamic memory allocation. C dynamic memory allocation refers to performing manual memory management in the C programming language via a group functions in the C standard library, namely malloc, realloc, calloc and free. To access structure member using pointers, memory can be allocated dynamically using malloc function defined under "stdlib. Define typedef. The typedef keyword enables the programmer to create a new data type name by using an existing data type.

By using typedef, no new data is created, rather an alternate name is given to a known data type. Define nested structure. A structure can be placed within another structure, i. A structure that contains another structure as its member is called a nested structure.

The easier and clearer way is to declare the structures separately and then group them in the higher level structure. When you do this, take care to check that nesting must be done from inside out from lowest level to the most inclusive level , i.

What is malloc? What is calloc? What is linked list? A linked list is a collection of data elements called nodes in which the linear representation is given by links from one node to the next node. What are the basic operations on linked list? Differentiate structure and union. Description Structure Union Keyword The keyword struct is used to The keyword union is used to define 1 define a structure a union. Size The compiler allocates the The compiler allocates the memory 2 memory for each structure by considering the size of the largest member.

Memory Each member within a structure Memory allocated is shared by 3 is assigned unique storage area of individual members of union. Value altering Altering the value of a member Altering the value of any of the 4 will not affect other members of member will alter other member the structure.

Accessing Individual member can be Only one member can be accessed at 5 members accessed at a time. Initialization Several members of a structure Only the first member of a union can 6 of members can initialize at once. Arrays Structure An array is a collection of data items A structure is a collection of data items of 1 of same data types.

Arrays can only be declared. There is Structures can be declared and defined. The 2 no keyword for arrays. An array name represents the address A structure name is known as tag. It is a 3 of the starting element. A structure may contain bit fields. Notes on deletion in single linked list. There are 3 situations for deleting the elements in a list.

How traversing is happen in a linked list? Traversing a linked list means accessing the nodes of the list in order to perform some processing on them. Remember a linked list always contains a pointer variable start which stores the address of the first node of the list.

For traversing the linked list, we also make use of another pointer variable ptr which points to the node that is currently being accessed. Define searching for a value in a linked list. Searching a linked list means to find a particular element in the linked list.

A linked list consists of nodes which are divided into two fields, the data field and next field. So searching means finding whether a given value is present in the data field of the node or not. If it is present, the algorithm returns the address of the node that contains the value. What are the functions supports for dynamic memory allocation? The functions supports for dynamic memory allocation are, i.

Write the routines to delete the first node. When the element is at first. How to traverse or display the linked list? Write the routines to delete the middle node.

Deletion at middle. How to represent a linked list using structure? Write the routine for create a linked list. When the list is empty. Write the routine for Inserting a node at first. Write the routine for Insert at middle. How to access the members of structure. A structure member variable is generally accessed using a '. The syntax of accessing a structure or a member of a structure can be given as:.

A dot operator is used to select a particular member of the structure. How to copy and compare structure. We can assign a structure to another structure of the same type. Write short notes on inserting a new node in a linked list. There are three situations for inserting element in a list. Insertion at the front of list. Insertion in the middle of the list. Insertion at the end of the list.

Explain linked list and its operation Store a collection of elements Node Declaring a Linked list Creating a Node Traversing the list Write the routines for deleting a node, inserting a node 2.

Explain dynamic memory allocation. Enables the C programmer to allocate memory at runtime Four functions 1. Explain nested structure.

Another structure as a member Two ways to define: Separate structure, Embedded structure Accessing Nested Structure 4. Explain self referential structure. To create data structures like linked lists, stacks, etc 5. How to define and use the structure? Allows you to hold different type of elements Defining structure Declaring structure variable. Write a C program to store information in structure and display it 7.

Write a C program to add two complex numbers. What do meant by file? A file is a collection of related records. A file can have fixed length records or variable length records.

How a file does is represented? A file represents a sequence of bytes on the disk where a group of related data is stored. File is created for permanent storage of data. What are the needs of files? To execute the program with large amount of input data is time consuming to enter the entire data. But, if file is created, this information can be accesses using few commands. What is file pointer? A file pointer is a pointer to a structure, which contains information about the file, including its name, current position of the file, whether the file is being read or written and whether errors or end of the file have occurred.

List the file attributes. Differentiate text file and binary file. Text file Binary file Stores data in the form of alphabets, digits and Contains a sequences or a collection 1 other special symbols by storing their ASCII of bytes made of 0 and 1. Small error in a textual file can be recognized and Small error in a binary file corrupts 2 eliminated when we see.

It cannot be readable by the human. Text file is created by the programmer. Binary file is generated by the 4 compiler. What are the basic operations of file? The basic operations in files are, i. Creation of a new file ii. Opening an existing file iii. Reading data from a file iv.



0コメント

  • 1000 / 1000