Programming in C BE All
Programming in C BE All
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
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.
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.