0% found this document useful (0 votes)
359 views2 pages

C Programming Model Question Paper

The document is a model question paper for the B.E. Computer Programming course at Purbanchal University, consisting of three groups of questions covering various topics in C programming. It includes questions on programming features, operators, functions, loops, structures, pointers, and arrays, along with programming tasks and theoretical explanations. The marks distribution for each chapter is also provided, totaling 60 marks.

Uploaded by

Ishwor Neupane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
359 views2 pages

C Programming Model Question Paper

The document is a model question paper for the B.E. Computer Programming course at Purbanchal University, consisting of three groups of questions covering various topics in C programming. It includes questions on programming features, operators, functions, loops, structures, pointers, and arrays, along with programming tasks and theoretical explanations. The marks distribution for each chapter is also provided, totaling 60 marks.

Uploaded by

Ishwor Neupane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Model Question

PURBANCHAL UNIVERSITY
B.E Computer/Final
Time: 3:00 hrs. Full Marks: 60 /Pass Marks: 24
BEG…: Computer Programming

Attempt All the questions.


GROUP-A 4x2=8
1. Write the feature of C programming language.
2. Define variables and keywords of C.
3. What is DMA?
4. Write the output of following program:
#include<stdio.h>
#include<conio.h>
void main()
(
int a=5, b,c;
b= ++a + a++;
printf(“a=%d and b=%d”, a,b);
getch();
}
GROUP-B 7X4=28
5. What is an operator? List various operators and explain any two of them with appropriate
example.
6. Write a program to convert US dollar currency into Nepalese currency vice-versa using
function. 1$ = 130 NRs
OR,
Write a program to draw line and circle in C programming.
7. What is function? Differentiate between Library function and User defined function.
8. What is difference between while and do while loop? Give suitable example.
9. Write a program to compute the product of nth terms of the following series
1*2*3*4*5* ……….*n
10. What is structure and union? Write difference between structure and union in c programming.
11. What is recursive function? Explain with any desire example.
OR,
Write a program to solve following equation:
E = 1/2(mv2) + mgh [Where E is Kinetic and Potential energy]

GROUP-C 3X8=24
12. a) What is pointer? Write function of pointer. Declare and access a pointer variable named ptr.
b) Write a program in C to perform arithmetic (addition, subtraction, multiplication and division)
operation by using pointer.
13. Write a program to create a structure name called STUDENT, add member as Rollno, Name, and
Age of the student and store student information to file specified by user using structure and
binary file.
14. Discuss basic concept of array. Write a program to accept n numbers of marks and display highest
marks.

Marks distribution for Computer-Programming:

Chapters Credit Hrs. Marks Distribution


Chapter 1 2 4
Chapter 2 2 2
Chapter 3 3 4
Chapter 4 3 4
Chapter 5 2 4
Chapter 6 6 8
Chapter 7 6 8
Chapter 8 6 8
Chapter 9 5 6
Chapter 10 5 6
Chapter 11 3 4
Chapter 12 2 2
Total 45 60

Note: This may vary for civil faculty.

Common questions

Powered by AI

The C programming language is known for its simplicity, efficiency, and flexibility. It offers low-level access to memory, a rich set of operators, and a variety of data types, which suits system programming. Additionally, it provides structured programming constructs and the capability to write complex programs with ease using functions .

In C programming, the "while" loop evaluates its condition before executing the loop's body, meaning if the condition is false at the start, the loop's body might not execute at all. Conversely, the "do while" loop evaluates its condition after executing the loop's body, ensuring the body executes at least once. "While" loops are often used when the number of iterations needs to be controlled up front, while "do while" loops are beneficial when the loop must execute at least once, such as in menu-driven programs .

DMA allows peripheral devices to access the main memory directly, bypassing the CPU, which is beneficial for performance. This capability reduces CPU overhead since the CPU doesn't have to be involved in data transfers between memory and devices. DMA operations are essential in high-throughput systems where large amounts of data need to be transferred quickly, such as in video streaming or disk operations, as it allows the CPU to perform other tasks concurrently, improving overall system efficiency .

Pointers in C are variables that store the memory address of another variable. They are crucial for dynamic memory allocation, efficient array handling, and direct memory access. To perform arithmetic operations, pointers can be used to access and modify data stored at specific memory locations. For instance, you can write a function using pointers to perform addition, subtraction, multiplication, and division on integers pointed by these pointers, which enables the manipulation of data through their addresses rather than direct variable names .

Keywords in C are reserved words that have a predefined meaning in the language, such as 'int', 'return', 'if', and 'while'. They cannot be used as names for variables, functions, or any other identifiers as they are integral components of the programming language syntax and control the logic flow. Variables, on the other hand, are names given to memory locations that store data used in a program. Proper distinction between these is crucial for writing syntax-correct and error-free programs .

Structures and unions in C are both used for handling data. A structure allocates separate memory space for each member, allowing all members to have values simultaneously, which is useful for representing complex data records. In contrast, a union uses a single memory location shared by all its members, with its size equal to its largest member, making it ideal for applications where variables share the same memory, such as in resource-constrained environments. Each has unique benefits: structures are useful for representing persistent data, while unions can optimize memory usage when data types are mutually exclusive .

A "STUDENT" structure in C can be defined to include fields like Rollno, Name, and Age. This allows each instance of the structure to hold these pieces of information about a student in a single container. To extend this structure for data storage, you can use the file I/O capabilities of C, reading from and writing to binary files. For example, open a file in binary mode and use functions such as fwrite and fread to store and retrieve structured data, ensuring data persistence beyond program execution. This method is valuable when managing large amounts of student data systematically .

To implement a currency conversion program using functions in C, you define two functions: one for converting dollars to Nepalese rupees and another for the reverse. Both functions take the currency amount as an input parameter and return the converted value. Since 1 US dollar equals 130 Nepalese rupees, you perform the arithmetic operation within the function: multiplication for converting US dollars to Nepalese rupees and division for the reverse. This separation of concerns into functions allows the main program to call these functions as needed, ensuring modularity and reusability .

A recursive function is a function that calls itself directly or indirectly. It is most beneficial when dealing with problems that have repetitive structure or can be broken down into smaller sub-problems, like computing factorials, generating Fibonacci sequences, or traversing data structures such as trees and graphs. Recursive solutions can be more intuitive and reduce code complexity compared to their iterative counterparts, although they may use more memory due to function call stack overheads. For example, recursion is often preferred in implementing algorithms for tree traversal since the structure of a tree naturally lends itself to recursive breakdowns .

Operators in C programming are classified into several types: arithmetic, relational, logical, bitwise, assignment, and others. Arithmetic operators (+, -, *, /, %) handle basic mathematical operations, e.g., a + b adds two numbers. Relational operators (==, !=, <, >, <=, >=) compare two values and return true or false, such as a < b, which checks if a is smaller than b. Logical operators (&&, ||, !) are used in conditional expressions to combine multiple conditions. Understanding and correctly using these operators is pivotal in constructing effective control flow and algebraic logic in programs .

You might also like