100% found this document useful (1 vote)
130 views11 pages

Programming in C BE All

This document contains a sample exam for a Programming in C course at Pokhara University. It includes 7 multiple choice questions testing various C programming concepts. The questions cover topics like: 1) Drawing a block diagram of a computer and writing a menu-driven program 2) Writing programs to calculate the area of a triangle and volume of a sphere 3) Writing a program to display a menu and perform tasks based on user input 4) Defining pointers, reversing strings using pointers, and finding the max in an array 5) Comparing structures and unions, and writing a program to store data in a file 6) Short notes on recursion, graphics functions, dynamic memory allocation 7) Al

Uploaded by

SUh-sUn StHa
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
100% found this document useful (1 vote)
130 views11 pages

Programming in C BE All

This document contains a sample exam for a Programming in C course at Pokhara University. It includes 7 multiple choice questions testing various C programming concepts. The questions cover topics like: 1) Drawing a block diagram of a computer and writing a menu-driven program 2) Writing programs to calculate the area of a triangle and volume of a sphere 3) Writing a program to display a menu and perform tasks based on user input 4) Defining pointers, reversing strings using pointers, and finding the max in an array 5) Comparing structures and unions, and writing a program to store data in a file 6) Short notes on recursion, graphics functions, dynamic memory allocation 7) Al

Uploaded by

SUh-sUn StHa
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 11

POKHARA UNIVERSITY

Level: Bachelor Semester – Fall Year : 2005


Programme: BE Full Marks: 100
Course: Programming in C Time : 3hrs.
Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.

1. a) Draw a block diagram of digital computer and describe each unit 7


briefly.
b) Write a menu based system which accept operator as well as 8
operand from user and perform the task according to user choice.
Operator Meaning
+ Addition
- Subtraction
/ Division
I Increment
D Decrement
2. a) Draw a flow-chart and then write a program to read three sides of a 15
triangle and print area for valid data and to print " Invalid data" if
either one side of the triangle is greater or equals to the sum of other
two sides.
(Area = s( s  a )( s  b)( s  c ) where a, b, c are the three
sides and s = (a + b + c)/2)
3. a) Differentiate between local and global variable with suitable 7
example.
b) Write a program to calculate and print area of circle and volume of 8
sphere of given radius. With the help of single function void
calculate (float radius, float area, float volume)
4. Write a program to display the following menu: 15
Menu
a) conversion of ASCII code to char
b) conversion of 0F temperature to 0C
c) multiplication table of given number
d) exit from program
and to perform task as per user's choice repeatedly until his/her
choice is to exit.
5. a) Define pointer. What are the rules to be followed while performing 5
pointer arithmetic operations and write the valid and invalid pointer
operations?
b) Write a program to reverse of string (Character Array) using pointer. 5
c) Write a program to find out maximum number of following 2-D 5
integer array.
int arr[3] [2] = {
{ 12, 29},
{ 30,40},
{16,10},
};
6. a) What difference between Structure and Union. Write about the 7
storage space (in byte) of they have same definition.
like –
Struct a Union a
{ {
int i; int i;
char c[2] char c[2];
}; };
b) Write a program 8
 To create a structure for Telephone Subscriber's data:
Tel no., name, address, previous month meter reading, current
month meter reading
 To write 100 customer's data in a file
7. Write short notes on (Any Two) 25
a) Recursion and recursive functions
b) Graphics functions
c) Dynamic memory allocation
d) Program Documentation
POKHARA UNIVERSITY
Level: Bachelor Semester – Fall Year : 2011
Programme: BE Full Marks: 100
Course: Programming in C Pass Marks: 45
Time : 3hrs.
Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.

1. a) Write an algorithm for finding greatest number among 'n' numbers. 7


b) What is an operator? List all operators available in C. Describe three 8
of them.
2. a) Why second generation of computer is better than first generation. 8
Differentiate between third generation and forth generation of
computer.
b) What are the steps involving during the programming? Explain. 7
3. a) Find out the output: 3
main ( )
{
int i = 5, j = 4, k = 9 ;
i = ( i + k)/3+k%(j+i) + j * k% i/2;
printf (“%d”, i);
}
b) main ( ) 4
{
int x = 16,y = 18, z;
}
y + = x ++;
z = ++ x + y++ ;
x = x + y + z --;
printf (“ \n x = %d\ny = %d\nz = %d”, x,y,z);
}
c) main ( )
8
{
int i,j,k;
for (i = 1; i <=3; i + +)
for (j = 1; j<=3; j + +)
for (k = 1; k< =3; k + +)
printf ( “\n %d%d%d; i, j, k);
}
4. a) What do you mean by selective and repetitive statement? Why do we 7
need break and continue statement.
b) Write a program to find the terms in the given series till the term 8
value is less than 250.
(12+22)/3, (22+32)/4, (32+42)/5,.............................
5. a) Give different ways of initialization of arrays. Give the classification 5
of arrays.
b) What is a function? Categorize it in terms of arguments and return 5
value.
c) Write a C program to find the maximum element in an array of N 5
elements.
OR
a) What do you mean by dynamic memory allocation? Explain about 7
memory leak.
b) Write a program to read N numbers dynamically and sort it using 8
function.
6. a) What is structure? Explain its components. How can you access the 7
members of a structure?
b) What is the significance of FILE Pointer? Create a structure called 8
Goods that stores Number, price, and PurchaseDate and Qty. Write a
program to store the information of 100 Goods into the file called
Goods.dat.
7. Write short notes on any two: 2×5
a) Pre- processor directives
b) String handling functions
c) Union
d) Dynamic Memory Allocation
POKHARA UNIVERSITY
Level: Bachelor Semester – Fall Year : 2012
Programme: BE Full Marks: 100
Course: Programming in C Pass Marks: 45
Time : 3hrs.
Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.
1. a) What is programming language? Describe Low Level Language 7
(LLL) and High Level Language (HLL) with examples.
OR

Explain briefly the various generations of computers with example.


b) Define Algorithm and Flowchart. Draw a Flowchart to read 3 8
numbers from the user and find the smallest one.
2. a) Define the terms operators, variable and constant with example. 7
Explain the necessary rules to define the variables name in C
programming.
b) What will be the output after executing the following Codes (assume 4+4
necessary header files):

i) void main()
{
int x=10,y=20,z=5,i;
i=x*(++y+z++)%3+y/x*2-5;
x+=z;
y-=z;
x--;
z+=10;
z--;
printf("x=%d\ny=%d\nz=%d",x,y,z);
printf("\ni=%d",i);
}
ii) void main()
{
char str[20]={"University"};
char str1[20];
strcpy(str1,"Pokhara");
printf("\n%s",str1);
strcat(str1," ");
strcat(str1,str);
printf("\n%s",str1);

strrev(str1);
printf("\n%s",str1);

}
3. a) Describe the different types of decision control statements used in C 8
programming with their syntax.
b) An electricity board charges according to the following rates: 7
For the first 20 units ------------- Rs 80
For the next 80 units -------------Rs 7.5 per unit
For the next 100 units ------------- Rs 8.5 per unit
For the Beyond 200 units --------Rs 9.5 per unit
and Tax 15% in total amount is charged to all users. Write a program
to read number of units consumed and print out the total charges.
4. a) What is array? Write a program to read values of 3×3 order matrix 7
then compute the sum of even elements.
b) What do you mean by function in C programming? Distinguish 8
between function call by value and function call by reference with an
example.
5. a) What is pointer in C? Can a function return more than one value? 8
Justify your answer with an example.
b) Write a program with user defined function using pointer to 7
convert all the upper case to lower case and vice-versa in a
string given by the user.

OR
Write a program to print the Fibonacci series up to N th term using
recursive function. The Fibonacci series is 0 1 1 2 3 5 … …. 7
6. a) Compare and contrast structure with union. Write a program 8
enlightening how to access the nested structure components.
b) Write a program by using structure that includes AccNo, CName,
7
CAddress, CTelNo and Balance for 100 customers of ABC financial
institution and store in account.txt file and finally display the
information of the customers who have the balance greater than
Rs 10000.
7. Write short notes on any two: 2×5
a) Macros
b) String functions
c) Global versus local variable
d) File opening modes
POKHARA UNIVERSITY

Level: Bachelor Semester: Fall Year : 2013


Programme: BE Full Marks: 100
Course: Programming in C Pass Marks: 45
Time : 3hrs.

Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.

1. a) Define Programming Language. Differentiate between high level 7


programming language and low level programming language.
b) Mention the appropriate data type for storing following data. Also 8
justify your answer in brief.
i. Distance jumped by a frog.
ii. A prime number between 5 and 555.
iii. Weight of your body.
iv. The examination symbol number of a student.
2. a) Describe the working of loop and while loop with flowcharts and 8
examples.
b) What is recursive function? Write a program to calculate the factorial 7
of a given number using recursive function.
3. a) Write a program to find the sum of all prime numbers in a given array. 8
The main function of your program should take the help of a user
defined function that tests whether a given number is prime or not.
b) Write a program to test, whether given two matrices are equal or not. 7
4. a) Write a program to insert a given character at the given array index of 8
a given string. For example if the given string is “Gnesh”, given
character is ‘a’, and the given array index is 1, the resulting string
should be “Ganesh”.
b) Differentiate between call by value and call by reference with 7
examples.
5. a) What is memory leak? Write a program to print reverse elements of 8
an array using Dynamic Memory Allocation.
b) Does a function return single or multiple value? When and how a 7
function will return single or multiple value, illustrate with suitable
examples.
6. a) What is a nested structure? Create a structure for the following data: 8
Facult
Roll. No. Name Address y Date Of Birth
        mm dd Yr
And Write a Program to input 100 students and display the records of
the students of "computer" faculty
b) What are file opening modes? Write a Program to open a new file,
read name, address and telephone number of 10 employees from the 7
user and write to a file.
7. Write short notes on: (Any two) 2×5
a) Pre-processor directive.
b) Nested loop.
c) String Handling Functions.

POKHARA UNIVERSITY
Level: Bachelor Semester: Fall Year : 2015
Programme: BE Full Marks: 100
Course: Programming in C Pass Marks: 45
Time : 3hrs.

Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.

1. a) What is a flowchart? Write an algorithm and draw a flowchart to 7


display whether a number is prime or not.
b) Why header files in C is included in program? Give reasons. Also list- 8
out different header files you know. Illustrate the program showing
the use of header file.
2. a) Define operator in c. List out different types of operators used in c. 7
Explain three of them with example.
b) An electricity board charges according to the following rates 8
For the first 100 units ------------- Rs 40 Per Unit
For the next 200 units -------------Rs 50 Per Unit
For the Beyond 300 units --------Rs 60 Per Unit
All users are also charge meter charge, which is equal to Rs 50. Write
a program to read number of units consumed and print out the total
charges.
3. a) Write a program to read a matrix and find the sum of all the digits in 7
its main diagonal.
b) Define function prototype? Write a program to read an integer number 8
and find the sum of its digits using recursive function.
OR
What is pre-processor directives? Differentiate between macro and
function with describing necessary example.
4. a) What is pointer? Explain memory allocation in C programming. Why 7
dynamic memory allocation is better?
b) Write a program using pointers to read in an array of integers. Next 8
add the elements in the array and display the sum on the screen.
5. a) Define structure and union. Explain way of declaring and accessing 7
member of them with suitable example.
b) Write a program to read the name, author, and price of 500 books in a 8
library from the file "library.dat". Now print the book name and price
of those books whose price is above Rs. 300.
6. a) What do you mean by nested structure? Write a program to explain 5
nested structure.
b) Find the output 5
void fun(int *p);
void main()
{
int x=4;
printf("%d\n",x);
fun(&x);
printf(“%d\n”,x);
}
fun(int *p)
{
*p=*p/2+13;
}
c) Differentiate between user defined and library functions with suitable 5
examples.
7. Write short notes on: (Any two) 2×5
a) Switch case statement.
b) Binary and unary operators.
c) File opening in C.

You might also like