POKHARA UNIVERSITY
Level: Bachelor Semester: Spring Year : 2009
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) Draw a block diagram of digital computer. Explain each unit in brief. 8
b) Differentiate between high level and low level programming 7
language. What do you understand by syntax and semantics of a
language?
2. a) Explain entry controlled and exit controlled loops with examples. 8
b) What will be the output of following program 7
main()
{
int sum,a,k,j;
sum=0
a=12345;
while (a!=0)
{
j=a%10;
printf("%d",,j);
if(j%2= =0)
{
sum=sum+j;
}
}
print("sum=%d",sum);
}
3. a) Trace the output of following program. 7
void main()
{
int x=0, i=0;
1
for (i=1; i<10; i++)
{ if (i%2 = = 0)
x += i;
else
{
x--;
printf ("%d\t", x);
}
}
printf("\nx=%d", ++x);
getch();
}
b) Write a program to read three sides of a triangle and calculate area 8
only if the given data is valid and print.
4. a) Differentiate structure and union. How the members of structure are 8
accessed? Show it with example.
b) What do you mean by user defined function? Explain storage classes. 7
5. a) Define pointer variable. What are the advantages of using pointer in a 7
function?
b) Write a program to find the sum of only even elements of 4 × 4 8
matrix.
6. a) Show the comparison between function call by value and function 7
call by reference with example.
b) write a program to read the name, author, and price of 500 books in a 8
library and store the information into file "library.dat". Now print the
book name and price of those books whose price is above Rs.300.
7. Write short notes on (Any Two) 2×5
a) File opening modes
b) Header files
c) Local and global variables