0% found this document useful (0 votes)
63 views

Computer Programming

The document discusses computer programming and problem solving in C language. It contains 8 questions related to basic C programming concepts like data types, operators, control structures, functions, arrays, structures, pointers, files etc. Some questions ask to write algorithms, draw flowcharts and develop programs to solve problems related to number checking, pattern generation, Fibonacci series, matrix operations, string processing etc. Overall, the document tests fundamental C programming skills through a variety of questions.

Uploaded by

Udaya Neupane
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Computer Programming

The document discusses computer programming and problem solving in C language. It contains 8 questions related to basic C programming concepts like data types, operators, control structures, functions, arrays, structures, pointers, files etc. Some questions ask to write algorithms, draw flowcharts and develop programs to solve problems related to number checking, pattern generation, Fibonacci series, matrix operations, string processing etc. Overall, the document tests fundamental C programming skills through a variety of questions.

Uploaded by

Udaya Neupane
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Pass Marlc

1l

Subiect: - Computer Progra,mmin1 "FJ! "0J)

,/ Candidates are required to give their answers in their own words as far as practicable.
,/ Attempt All questions'
'/ Thefigures in the margin indicate Full Mqrks.
/ Assume suitable data if necessary'

1. a) What is computer program? Discuss in brief about different generation


prograniming languagis. [1+4]

b)' Vfhy is algorithm and flow chart development important in problem solving? Write an .
algorithm-and draw flow chart to test a number entered by user whether it is even or
not. 12+31

2. a) What is the identifier? What are the ways to give value to variable? Explain with
example? [1+2+1]

b) Explain about input and output function available in C with syntax and example of
eachpart. [Z+2+2]
I a) Write algorithm, draw flow chart and program to input a number check it is
Armsffong or not. [2+2+21

b) What do you mean by selective and repetive statement? Why do we need break and
continue statement? t2+21

4. a) What do you mean by "call by value and call by reference"? Explain it with suitable
example. L4l

b) Can we pass whole array element from the function? Write the program to pass an
array to function and sort them. t6l
5. a) Write a program that finds the largest word in a given sentence. I4l
b) Differentiate between the methods of passing argument to function with example.
What are their advantages and disadvantages? t6l
given in
6. What is structure? Why is it necessary? Write a program to add two distances
feet and inch format rlring structure. [1+1+6]

7. a) what is nuu ***';X:r.:: **ut orrollowins prosram, explain. [1+3]

ff
int mainQ {
if( ! NULL )
{. prinff("C programming is easy");
else
printf("C programming is not easy");
return 0 ;
)
b) Write a program to calculate the length of string without using string handling
function. t4l
8. A file name employee.txt stores employee name, employee id and employee salary. Write
a program to diiplay the detail of all employees in the order of their salary. [8]
q read 10 integers from user and short them in ascending
It I

,I'RIBHUVAN
A2 LNIVERSITY
INSTITUTE OF ENGINEERING
Examination Control Ilivision
2074 Ashwin

$nU_qg!: c";t{; p;d;il* ;iie Grao t t


Candidates are required to give their answers in their own words
as far as practicable.
Attempr l!!questions.
The Jigures in the margin indicate FulI Marks.
Assume suitable data dnecessary.

\: l. whaj a1e c-omp]rter programs and computer programming?


Explain the steps that are
required to build a computer program foisorving a certain pioblem.
., 12+61
L. Explain with an example the rgle that precedence and associativity
play in the execution
of an expression. Rewrite the following program by correctiag
any effors, if present and
also write down the output of the corrected code.
[4+4J
Define MAX 5,
int main { }
{
int case[M&(l=12p,5,4,10],i,sum=0;
for(i=O,kMAX,i+=1)
{.
print("Case %d = %3.2d\n',,i,case
[iJ);
SUm +=+ CaSe+i;

h
average = sumlMAX;
pr ntf{ "7o06. 2f ', ave ra ge}
i
;
return 1;
,

3" a) Compare if-else-if la<Ider and switch construct with example and flowchart.
isl
b) ]vrite a Program in C to generate following pattern using unformatted inpuloutput
functions onlv.
[-{]
al
t\
FF>

PFPP F
aaaaa aa
LLLLLL LLL
4' v/rite a program in c to find out whether the nth term
of the Fibonacci series is a prime
number or not' Read the value of n from the user and
display the result in the main
function- use separite user-defined functions ro generare
r#';in il";;;;; i.rr" *0,"
check whether a nurnber is prime or not.
t8l
t 5' a) How two dimensionar a*ays are
created i1,c plgramming? write
NxN and find sum of botir ailgonJ.. -' to
squaxe matrix of size yvrrre a program
to read
t) in C to check whether a given [z+4]
xilHffif;ffi srring is parindrome or nor
using user
6' What are the advantages of
using poinrer in C I4l
largest -r"."*r-r'J'f;';", n1q1m*:ng?_ Write a program in C to
.ontui'ing N:"r"m"nts using
ff*,:::t* concept of
7 ' Explain structures and nested
skuctures? create a stmcture to hold
12+41
x+iy' write a program that uses any complex number
third cornplex number which
tt" t*"t* to read two comprex numbers
and dispray a
ir1rr" *Jiiprication orth"
8' """r* ""rpl;;;'#;;t t3+51
"' ,H;lHoT*fr:J*ut/output tuncrions used with data files
in c? Explain with
b)
write a program in c to read
integers from user until user
I4l
say.s..no,,. After reading
odd numb." io-u nr" the
lff.Hff.r*le "u'";dd;;'", *" even number to file
9' when can we use recursive functions? I4l
programs? Differentiate Iev ao we need conftor srarem€nts
statem€nts in com;
between do...while *a ror computer
rrui"i"-;,:'.*",
l0' what are the characterisrics of F'RTRAI [2+2+z]
to calculate the value of n bv lggramming? write aprogram in F'RTRAN
evaluating
;;;h,r,"
the rottwing irrizJ-**r. '
t8l
-\- '1 7 1 \
n=+(t--l
s*s-l*A-..,)
*,r*
05 TRIBHUVAN UNIYERSITY
,t
INSTITUTE OF ENGINEERING
Examination Control Division ALL (Except B. Arch)
2073 Shraw&n

Fy?irsl:_9g_*sggrlss*jss(9ruJ)
Candidates are required to give their answers in their own words as far as practicable.
Attempt AIl. que stions.
TheJigures in the margin indicate Full Marks.
Assume suitable data if necessary.

L a) What do you mean by Programming Language? Explain about ,t, .uot*ion of


pro gramming languages. [1+3]
b) What are the advantages of a Flowchart design? Write down the guidelines to be
followed to draw a flowchart. 12+21
2. a) What is the purpose of the semicolon that appears at the end of most assignment
statement in C? Explain the program compilation, linking and loading process with
example. [2+41
b) Discuss the types of errors in programming. Horv do you debug a C-program? 12+4)
3. a) Explain relational and logical operators. t4l
b) Write a C program to display following pattern without using formatted inputloutput
statements.
t4l
Programming
rogrammin
ogrammi
gfamm
ram
a

4. a) Why do we need control statements? Compare switch and if-else-if ladder with
example. .
t4l
b) Write a C program to display all characters between a given ranges. t6I
f. a) What are the advantages of using functions? Differentiate between Library functions
and User-defined functions with suitable example. tsI
b) Write a progfilm to check wtrether a given number is Armstrong number or not using
recursive funetion. t5l
a) Write a C program to read two strings in main and compare them using userdefined
function.rDisplay appropriate message from main. t4l
b) What are overflow and underflow elrors in context of array? Write a progffim to add
corresponding elements of two arrays. The results should form a new array. [2+4]
7. a) Why should we prefer structure over array? Explain nested structure with example. 12+41
b) Write a progfitm to read name and roll number of 48 students from user and store
them in file. If the file already contains data, your progftlm should add new data at the
end of the file. t6l
8. a) What is the structure of FORTRAN program? tsl
b) Write a FORTRAN program to read n numbers and display largest number among
',*

05 TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERTNG
Examination Control Division
2A72 Chaitra

* F r$:s!: :"c9qp$s:$eslsnnlgg g!!o ! )


Candidates are required to give their answers in their orvn words as far as practicable.
Attempt All questions.
The figures in the margin indicote Full Mat&s.
Assume suitable data if necessary'

1. a) What is a flow chart? Use the various commonly used floW chart symbols. How does
a flow chart help computer programming? [2+2+21

b) What is a program? Brietly describe types of computer software. I2+2\


2. a) What is an operator, datatype, constant and variable? Define. t6l
b) Define and write syntax of the following: t4l
t getsQ
ii) putcharQ
iii) scanfQ
iv) strlen$
3. a) How is the switch statement used in decision making? Explain with a suitable
example. t4l
b) Write a program to check whether a given integer is a triangular number or not. i6l
(Any number is a triangular number if the sum of nqtural number from I to any number i
is exactly equal to that number. For e.g 1,3,6,1A,15 etc are triangular number as,
l+2=3, J+2+3:6, I+2+3+4:10, I +2+3+4+5:l 5)
4. a) Briefly explain the passing by value and passing by reference in function with
example. t6l
b) Write a program to calculate sum of digits of a given S-digits number entered by the
user using recursive function. t4l
5. What is a string? Write a progmm to read a 3*3 square matrix, find minimum integer
value of a matrix, replace the diagonal elements by the minimum element and display it
using pointer. [2+8]
6. a) What is the principal difference between a structure and an anay? t21
b) Write d program to read structure "college" having name, estDate and location where
estDate is an another structure having day, month and year as members. Display the
records of l0 colleges. t8l
a) What is a data file in C? What are the modes in file handling? Explain briefly. [1+3]
b) Write a program to read the information of a file named "data.txt" and write its
contents to another file "record.txt". t6l
a) Compare DO and implied DO statement in FORTRAN. t3l
b) Write a FORTRAN program to add and subtract two matrices and display the results
in matrix form. t71
'3?. ..,

/
r'.
r'

1. a),,

b)

3. a)-

l;. a_-

.,
i

b) Write
the element
8. List different tlpes of stsdard VO used iu C. Write aprogrysl to write name, roll
age of five shrdents into a disk file aame " STUDENT.DATU.

9. a) Explain differe,nt [pes of goto statements in FORTRAI{


example. Write aprogram. to read n from user and display
till ns terms: 1+(l+2)+(1+2+ 3)+(1+2+3+4)+.... -...I1 [4+4]
' '
b) Explain with suitable example to show how an Impiieri Do loop works in FORTP,AN. t4I
:*r.*

P.1.21,
05 TRIBIIUVAI.I UNITERSITY Exam..
. INSTITUTE OF Level BE Futll!(!rLsl 80"
Examinaticn, Prograqme AII @xceptB. Arch) P+s,! Mar.F
2A7L Y.ear /'Part Itl Tiine' 3 hrs,

b) WriteaCprogrqm that
computer- rearra[ge tlren@es t4I
7.. Iltustate with example that "Array* is indiiectly a pointer". Write program to calctrlate
sum and average of integer numberi between M'and N (where value of M and N are read
from keyboard) usingpointer- 14+4J

8. Write a program to contiduously read rvtme, age and salary of a worker and write it into a
file rmtiiusir confirmsio end- Then read n from user and display the n6 record in the file.
Details of worker must be represented by a sEtrcture. tl
9. a) Compare arithriretic and logical if staternents inFORTRAN U1
b) Write a FORTRAITI prograrn to display nature of roots of a quadratic equation.
Calculate and display {he roots, if they are real and equal. pl c1

I :1. {.*

P.1.22
lj

05 TRIBHUVAI.IUNIVER.SIfi Eram.
'l
Level Fult [Grks 8

ExamiRation Control Division Programme trIl (Exc-eptB.Arch) iass Marks


Ycar./Part Ut .:,.
Time

program

W.ritp qmtan,
i) pintf( )

:1..j, , ,

'r;...-: '-

,do.,,,, while lo,9R the progran "to find


. rlrl..-.i, ,

13+71

.i;;
'Ir i'
f.
:: ': '
of n+uqber uili.l the , . .
I I . . ,,i ' i ::.: :. {2+2+4J
:J.: a) Write a order.
3,'sales.
,. ,Each sales of
Calculate .-

'6. a) 4bout t4l


a
' .; l
to swap the value of
function. [2+61
8. \l/ritg 4 C progr4m to store ernployee dglails in a text fiIe. Read,data from.the text file, .

sort them ia ascending ordei of salqry and store the sorted record to a binary file. Display
the details and rank of employee given by the user. . t8]
g. a) What do you mean by formatted and unfonnatted input/output statements in Fortran .

and also give suitable example which explain the concept of Formatted UO. t8l
b) Write the program to convert a binary number to a decirnal number using Forkan
progra@ming language. t4l
:
t**

P.1.23
05 TRIBHUVAN I.JNIVERSII'Y Bxam. c11 r
INSTITUTE OF ENGINEERING Lev-el- Full Marks 80
All ( Except'
- Examination Control Division Programme
.
Pass Marks 32
B. Arch ) ;, "
2070 Ashad Year / Part Ill )t, Timc 3 hrs.

,/ Candidates are required to give their answers in their own # practicable.


{ Attempt AII questions.
{ Thefigures inthe margin indicate Full Marles.
{ Assume suttable data if necessary.

l. 1)zDefine software. Explain its types. .,1;: t3l


&)z What are the steps required to develop a computer program? Explain. tsl
2. *z'1l What are relational operators and assignment ffperators? Explain with examples., t3l
'b) Rewrite the following program
by correcting any syntactical errors, if presend' Also
show the output of the corrected code. [3+2]
#Include <stdio.h> "o
int main ( )'
t
' float root int i= I;
do { sum=2i- l;
print ("\P/od\n,', sum)q
i *- 513;
I while (swn <: [5)
root = pow (i, l/2);
v print ("\n7o.3f ', root);
return void;
)
t,
3
v \tr/rite a program to read the number until - I is encountered. AIso count the number
even number and odd numbers entered by the user.
of
t6l
b) Distinguish between break and continue statement with example. t4I
4. a\ Explain how function is defined in C? Differentiate call by value and cail by
reference. [+2]
b) Write a program using a function that returns the largest number from an array of
numbers that is passed to th9 function. tsl
5. a) How are one dimensional and two dimensional arrays created in C? Explain with
examples. l2+2J
b) Write a C program to read two matrices from user, add them and display the result in
matnx form. t6l
6. What do you mean by nested structures? Give suitable example. Write a program to read
' the Heights of two students and display the difference between their heights. Use feet and
' inchcs as members of a structure to define height. 12+61
'a)
7. Compare array and pointer with example. t3l
b) Write a program to read a string from user and use a user defined function to copy the
content of the read string into another character array changing lower case letter to
upper if any. Use pointer to process the string. tsj
8. Write a program to read the details of book authors and write it to a file, until the user
- confirms to end. Then read and display the nh record in the file, where n is read from the
' user. The data for authors must be represented by structures that contain name, nationally
and number of books published. t8l
;,9. a) Explainthe FORTRAN structure. What are data types in FORTRAN. 12+21
in ptoper
t) rprlt" a prog1am in FORTRAN to solve quadratic equation and displav roots rbj
format. ,kd.*
'1
f
1
I

't I
I

- I

-l

-'1
I

-1
t2 l2o
, .

22 TRIBHUVAN I'NIVERSITY Exam. Old Back Q065 & Earlier Batch)


INSTITUTE OF ENGINEERING Level BE Full Marks 80

Examination Control Division Programme BEL, BEX,BCT Pass Marls 32


2070 Chitra Year / Part Ul Time 3 hrs.

Subject: - Computer Programming | (EG442CT)


{ Candidates are required to give their answers in their own words as far as practicable.
{ Anempt All questions.
{ The/igures in the margin tndicate Full Mailcs.
{ Assurne suitable data if necessary.

t. Why do we need programming language? Write down the advantages and disadvantages of
high level and.low l9v9f programming languages. Write an algorithm and flow chan to
check whether the given yedr is a leap ]reaI or not; [Hint year is a leap year if it is divisible. -
ty 4 not by 100 and by 400.1 ^ 12+3+51

2. What do you mean by operators? Explain differcnt operatorc along with their precedence
and associativity. Write a program to count the number of vowels in a string you ar€ not allowed
touse library functions. 12+2+61

3. What is a nested if-else statement? Explain it with an example. Write a program to find the
largest ofthe three numbers using a nested if-else statement. U+2+11
4 Compare while loop, for loop and do-while loop. Write a program to evaluate the following
0.001.
series until the difference between the two terms is less than [3+7]
13 xt
.S-=f+3-+-+...
" 3., 5!
5. Explain why we need function in programming, Write a function to check whether a
number is prime or not and use the output of that function to print prime numbers from I to n
entered tiy the user. 13+71

6. What is a pointer? Write down the relationship of aray and pointer. Write a function that
takes string as an argument and return the number of characters in the string. Also return by
converting the string to upper case. Don't use libraryfunction. [l+2+71
; How is nested structu€ formed? Explain with example. Write a program to perform
additioq subtraction, multiplication and division of complex numbers. Make separate
functions foleach operation. tl+2+77
E. What are binary and text frles? Write a progftm to write any structure information in a
binary file andtotead and displayillater . Make a menu driven program to read and display
information from file. [3+7)

* *tt
t
,'t*
:

05 TRIBHWANI,JNryERSITY Exam. lltcgular


,BE
INSTITUTE OF ENGINEERING Level Full Marks 80

Examination Control Division Programme AII @xcept B. Arch) Pass IVIarks 32


2070 Chaitra Year / Part Ur Time 3 hrs,

r' Candidates are required to givi their answers in their own words as far as practicable.
{ Attempt All questions.
{ The/igures in.the margin indicate Full Marlcs
/ Assume suitable data if necessary.

What do you mean by software and explain about generation of programming


J/4 14 l
Define the term "Flowchart". Discuss about different symbols used in Flowchart. [4
Z- 9{iAa out final value of a, b and c where following expressions are executed
sequentially t4l
int a=2,b = 3, ci
a= (b+) + 1++b) + a; lo
,/ Q=o>b?aib; 3
'6 = (a++) + (b-) +a;
V
c = c+t_*b_-i S

b) What are the difference between formatted and unformatted UO statements? Describe
with proper example. t4l

!*Y exylain importance of break and default statements in swirch statements. tll'
b) Write a C program to display following pattem using unformatted output statements: l7l
P

Pu
PUL

PULC
{'
Pul.cH

pulcHoW
PULCHOWK
/
4.\af Dqfine "firnction definition" and write the program to find the sum of tu,o numbers
using user-defined functions. t{L
yI Wtlm;t do you mean by "call by value and call by reference" along with suitable
: -:
examFle? I{]
S/Canwe pass whole array element from funotion? Write a program to display only those
students infomration which are passed. Use separate function to check the result of
student. The information of students like Name, Roll No, Address and Marks are passed
from mainArnctions and pass to functions using array t)?e arguments. L2+8I
M:.t--

A.
-/'r{nxplain
the use of t5,pedef of keyboard in structures. 12)
b) the need.of nested structure. Writeia C program to convert data in BS to data
y-/ /xplain
in AD using structure. Use the data difference of current'data. tl*S]

t3]
t5l_

l4J

t4l
t4l /
Srf'W;te a FORTRAN program to read m*n matrix, transpose it and display both the

**
il

i ,]
ri
,..-,,,,,.. . -. . -r -.-.,',i.J' ;i
-ll.
li
I

i
:

''t:; .
-l

I
I
I

05 TRIBHWAN T'NIVERSITY Exam. Nen,Ilacli (2066 & Later, Batch)


INSTITUTE OF ENGINEERING Level BE Full Marks 80
Examination Control Division
i'
Programme AIlGo""pt n. rrct.) Pass Marks 3.t

2069 Ashad Year /Part lll Time 32 hrs.

s
')
/ Candidates me required to give their answers in their owr: words as far as practicable.
{ Auempt.AlI questions.
l

i '/ Thefigures in the margin indicate Full Marks. '!

{ Assume suitable data if necessary.


i
I
I

I
Vt Dry"rentiate between high level and low level. Explain the steps of solving a problem I
I
using computer- [4+4]
'
2. Consider a statement
scanf ("8s", str) ;
Where st is a string variable
In above statement, why '&' symbol is not used? Can we input string with space in this
statement? If not, why? t4l
\,
fu \Vrite a program in C to find all possible roots of a quadratic equation a:r2+b>i+c=0. t8]
-.$--Wlile
'r" v $to:un sieniticance qf u'pin()$n-ction in Ci Diftereajate betwe_en pas,!y.lalrl9;,_ :e
-
and pass by reGrEnce arguments. Describe both witJr meaningfuIexample. ! 12+61
{ 5,. Explain how array can be passed to firnctions. Write a program that passes an array to a
\/ firnction and print the largest and smallest element.
\ [2+61

-Q How are sEuctures different from arrays? Create a structLue in C to store the name of a
v batsman, runs scored and no of times the batsman in dismissed. ln the pregram, read the
data of five players and display the batting average of the player whose name is entered
totalruns/total-dismissals. ,t
by the user. Batting average is given by [2+61
Wnte down advantages of pointer. What type of arithmetic operations can be
t l- implemented in pointer? Also describe the relationship between array and pointer with
appropriate syntax and examples. ,f [2+3+3J
8. Write a progr.un in C, to read the following information for 96 shrdents.
Student Name, Student roll number, Marks obtained(in 100)
Record all data in "ioe.txt" file, and program should print roll number and name of
student who have obtained greater than or equal to 40 marks. t8]
9. Rewrite the following source code correcting any error present in it. Also indicate the
error corrected in comment. Then write the output of the program. 14+41
,
-
I

?
/programto convert list of temperatures
/in Centigrade to Eahrenheit .
*inclucie stdio-h;
int main ( )
8'
L .rL.
{
int i, n-3;
float celc Ini , faren In] ;
6sg1i=0; i<n; i++) :l
{
. Print ( "CeIc t tdl =" )
scanf ("td", ceicIi] ),'
]
' ' t
i6nlrert (berc, faren, n) i '
for (i=0; i<n,. i++) print lfarenii) ) ;
break;
);
void convqct:(.ftoat,c.eAlJ, rftroat. fa:r[], int n)
1

forli=0, i<n,' i++) celzfar(farIi]i celIil);


i;
cel2far(float f, float c) \
{ f = 9/5*c+32; !; i,:
,,I
10. it with implied '/
them in array,
*lJile
I., e
.11. What the syntax of two dirrrensional in FORTRANI Expiain \{ith exampie.

v
['+.1

l/- ***
j

i,

/
"05 TR]BHWANUNIVERSITY Exam, Resular / Back
INSTITUTE OF ENGINEERING Level BE FulI Marks 80
Examination Control Division All (except
Programme B.Arch) Pass Marks 32
2058 Baishakh Year / Part ilr Time 3 hrs.

I
t' Candidates are required to give their answers in their own rvords as far as practicable.
{ Attempf&.qtrcstions.
,/ Thefigures in the margin tndicate Fu!!@fu.
/ Assum.e suitable data if necessary.

1. What is high level language? Write different types of high level programming languages with their
examples. Hpw compiler is different than assembler programming language? [1+4+3].
'.'2. What is a pseudo code? How is it different from an algorithm? Draw the flowchart to solve the
multiplication of two matrices. U+2+51
l. Write a hierarchy of operations of the following expression in computer programming C: IEOF tt
B-Salary + Daily-Allowance > 8000&& eligible_code =: 1tt nelpay>10000. Write different forriraited
input output used rn For Tran programming language. [4+4]
4. Write a program.in C to calculate the frequency (F) for different values of cap.acitanees(C), for a certain
electrical circuit. with an inductance (L) and resistance @), the darhped natural frequBncy is given
by-F:./11tll.Ci-Cn'zl+C11.-It is.iequired to study ttr'e variation ottiis frequencyw^ith capacitance
starting frbm 0.0.1 to 0.1 in steps ofb.01, and calculationlhould be,dohe.u$ing uqbr defined.function. [8]
5. Write a syntax in C- programming wittr example of the following: "scanf', single statement
"do....while", "strcpy'', structures with arrays. fax?J
6. What are the rules that govern the passing of arrays to user defined functions? Compare'"user defined
functioni' and "switch" in C- programming language. [3+5]
7. What are the importances of "Pofutters" in C programming language? Write the output of the following
program. L4+41

# include<conio.h>
voidmain0
, t int k; int.a[ ] = {1, 2,.3};.int*b[3]; int **c[3];
int***d[3] ; int* **,Fe[3J. 1o1**** *,f[3];
clrscO;
for g =' O;t<:; t++1 i
{ blkl.: q+ hclkl :b + k; d [k] : c + k'
e[k]:d+k;f[k]:e*ki
il
fo. (t --L;t.3;k+-r)
t printf ('oA3il', *b[k]; printf ("%3d", **c[k];
printf ("%3d", ***d[k]; pintf ("Yo3d', ****e[k];
Printf ("%3d\nr'
*****f[k] ;
)
)
8. Write a progtam to read name and age of 10 different students as the two members of a structure named
"studeirts". Display the name and corresponding age of the students sorted in an alphabetical order. t8]
g. What are the inputs and outputs functions used with data frles? Explain, error handling process d-uring
reading and writilg in a data files. t5:31
i0. Write a program in ForTran to test whether the acceptcd year is leap year, or not. (Hint: A year is
leap year if: the year is divisible by 4, but not by 100 or the year is divisible by a00) t8l
rl
:1. {.*
I

I
t

iltl
l
I

tilr

i
I

\
,,:a

06 'I'RIBHUVANI.JNIVERSITY Exam. New Back (2066 Batch & Later) .


INSTITUTE OF ENGINEERING Level BE Full Marks 80,
Examination Control Division All (Except
Programme Pass Marks 32
B.Arch.)
2068 Shrawan Year / Part TIT Time 3 hrs.

Subject: - Computer Programrning


'/ Candidates are required to give their answers in their own words as far as practicable.
,/ Attempt All.questtons-
./ Thefigures tn the margin indicate l:ull,Mqiks.
,/ As-rume suitable data if necessary.

1. Define algorithm. lVrile an algorithm for finding largest and smallest values from a list. [2+6J.
2. Draw a flowchart and algorithm to find roots of a quadratic equation (ax2 + bx + c : 0).
Include all three conditions of the determinant. I [10]
3. Write a program to read values from user and find sum until user types 0, also display
sum and average. t8L-
4. &Ihy prograillmers prefer using user d.efined functions? What is merits and demerits of
using functions in program? Differentiate actual and formal parameters used in functions.[3+2+3J -

5. Write a pro$am to take a list of values from user into an L$ay. Pass the list to a function
which sorts thq vaiues in ascending order. Display the sorted list from main program. [315]
6. Write a proglam to represent cornplex number by a structure with real and imaginary as
members. Take 2 complex numbers as input from user into structure variables. Pass the
complex numbers to a function which calculates sum and returns it. Display the sum from
anothgr tunction displayQ. [10]
7. What is the role of pointers in
passing parameters to functions by reference? Give
example, how 2 dimensional array can be accessed by a pointer. 14+41

8. \lhat do you mean by opening a data fiie? Iiow is this accomplished? Explain fscanf,
&rintf, fread, fwrite functions. [l+3+4]
g. Explain the skucture of a FORteX program. Differentiate between arithmetic and
logrcai if statemenl 1Z+Z1t
10. Write a program in FORTAN to read two matices from user, find their srmr and display
the sum. t8l
**rf

L
i
I

i
ir

i
I
i
1 I

-t I

'1
I
I

I
I

-''l

i
I

-t

i
I

I
I I

I
1

I
a.**J 05 IRIBHUVA}ITJNIVERSITY Eram. RegulariBatk
INSTTTUTE OF ENGINEERING Level BE tr'uU Nlariis 80

Examinatlon C on rrol Divisi,*rr All @xcept


Prograrhme Pass ^\Iarks 32
B.Arch.)
2067 Ashadh Year / Part UI Time 3 brs.

{, Candidates are required to give their answers in their oum words as far as prdcticable.
{ Auempt All questions.
,/ Thefigures inthe margin indicate Fult Marks.
/ Assume suitable data if necessary.

1. What is high level language? What are the different types of higfu lwel languages? How
computerprogramming language C is different from FORTRAI.I? [1+]t{
2. 'Write an algorithm aud flowchart of the distance betwee,n two points (xr, yr) and (x2; y2), I

I
govenred by formula Dz = (xz - *r)' + (yz- y1)2. Where, xr, xz, yr, yz ari given by user,
I

.::... ... ,
ts+fl'"
3. Write a qmta:r used in:C prograinming teinguage for the followings: tHI
a) scan( ) b) while c) stuct

4. What are the significant meanings of '&' and '*' established in C programming? How .

car you differentiate between 'ciIIed by value' and 'called by refereuce'-with irt
C programming?. : "*iropt.
t4+61

5. State with example, how switch () function differs from user defined function in
computerprogramminglanguage C. t4l
6. Write a pseudocode to find the standard deviation of an array of values in C
'
programming. The array ele,ments are read from the terminal. U'se user defrned functions
to calculate standard deviatipn and mean. Standard deviation of n value is given by ,EI,
1-',.'E;;;
,

r'=
1= ,
Where x, is the'mean of the values.
'Write
7 . prograur in C programming language accor<li.g to the output displayed below: (to
a
open a file named RECORD.txt for the n number of data where Cost, Service Charge 5o/o,
VAT 15%, and Total Cost must be calculated by program itself). [0]
Output is:
Item Code Description Rate Ouantitv Cost
OOlCT Computer 22.000.00 5 110.000.00
007M Cell Phone E,C'00.00 IO 80.000.00
VAT 15-"/C

Sersice Charge 5%
Total Cost
Thank You!!! Visit Again
I

-1
1

I
8. Rewrite program correctly and write .oritput of the glven proglam written in C
programming I anguage below : t8l
# include stdio.h
# include conio.h i
I

void main( );
'{ : {'t"'o"'E"'
char arl[1 1]
char ar2[15] = "IoE, Pulchowp';
"'P"'IJ"'L"'C"'Hi,'O"''W"'K',};
char ar3[1 1] = { {'I'},{'O'},{'E'},
{''},{'p'},{'u'},{'L'},{'c'}, {'H'},{'o'},{'w'}, {'K'};
clrscsr( );
{printf ("\nArray l: o/oc\n", arl);
riit"tf Cf"arrayz:o/*Yl',lr2,)i' :
I

priutf ('lnArray 1: %c'rn-', [3); l

retum 0
)
9. Describe the formatt$ inpu! and output statement ip IOR'[RAI.{ programming language
with it's syrtax. I4l
10. Write a program in FORTRAI.{ to evaluate the following series: t8l !

series.: 1/11 + Ll22 + lt32 + ... ... ... + lN


,f :f !f
I
i

,I
'22 Tir ":,'..'-{1IUNIVERSITY r- ./ E:r ik
INSTITU' - ,T ]N:-iNEERI]' BE Fuii ]i: rks 80
'
r., i aminal l. * :..Onti'Ol [)iv.i:ii :: BEL, BEX,
Plls..; .r. I,i::ks 32
BCT
2CSi ihra;,'an \'ear lPzrt I/i Ti;:re 3 hrs.

Subject ter Proprarnn'ring I


Candidates are requr-;?d to give thelr answers in their own words as far.as'practicable.
, Anempt ilil questioi;s.
'/ Thefigures in the margin indicate Ata*s.
- 'r' Assume suitable date if necessary^. Z"U

1. a) What are'the-Cen:erits of C programming? Fiowchart is representation of an


. algorithm. Jushfy the statement with suitable example. 12+21
b) Draw a florvchart and then rvrite a program to read three ,iau, oi ri*gt" and print
"
area for vaiid data and to print "Invalid data" ifeither one side oftiangle-is greater or
' equals to thq sunq of othertwo sides. [Area=
66:AGTC;O,where a, b, c are
t"'. ""= ..,, threesid.dsands=(a+b+c)/2. .' ' . .' _ t4]
2- a) Describe the meaning of precedence.and associatively of operators with suitaLle
example. How much memory is required for long integer and its range? [2+41
b) Write a progam in C to calculate the sum of given series up to the term given by the
user. :
l4I
Y = L 12 - 2/x2 + 3lx3 -.................,...........
3. a) Distinguish betrveen call by value and call by reference with example in C. 12)
b) Write a program in C to find trace and norm of a matrix. Trace is defineC as the sum
of principal diagonal element; Nonn is defined as square root of the sum of the.squars
of all the eiernents inmatrix. .t6l
4a) Ciassify the variable according to the scope aod exteqrt (Storage class) with C. 121

b) Write a program in C which calculates F, where p,= (a t bn)/ c!,and n is. an integer.
For designing above program, use two functions, one calculatbs factorial and other
calcuiates power of anumber. t6l
s. a) Wlry pointer operator is called indirection operator? Give example. t3l
b) Write a C program to check ryhether the given sfting is palindrome or not. Palindrbme
shorild be chEcked by user defined function. tsl
6. a) What are the differences between malloc( ) and calloc( ). Wheu we use realloc( ). [2+1]
Write a C program to read n integer numbers in an array dynamically and create two
functions to sort in ascending and descending order and display the result in the maiu
,, function. tsl
'7." a), Discitss [6r'r arra] of strings can be stored in.ai-ray of pointer variable. t3l
b) Write a C p'rrsglam to enter the strings uatil the user enteis "end'; and display the list
of string in aiphabeticai order using two dimensional array of character usirg
flrnction. tsl
-t!
i

-l I
I

8. a) Explain nested struchre in C, with example. l3l


b) Write a C program that illustrates the pointer pointing to the function. .
tsl
9' a) How can we'pass structure variable as a pararneter in function. Illustrate with an
exari,rple. l2l
b) Create a structure Shrdent(Roll, Name, Address, Age) to store 10 different records of
students and ariother structure Marks_Sheet(SN, Subject_Name, Full Marks,
Pass-Marks, Marks-Obtained) within Snrlent tL store the records of S different
subjects. Write a program to enter the records of students and display tLe records with
the percentage each student have scored. l6l
10. a) In which condition unary operator is equivalent to assignment operator. Explain with
exa:nples. l2l
b) Write a program in-C to create a file named "subject.brt" that stores subject name,
subject code and full marks where subject na:ne and subject codes are stings and full
:r,".; 1

marks is float. Also display aillhe records stored in the file. Write. a.progarfl to keep t\
the records of 10 subjects and display allrbcords from the file. t6]

,c

nl i

"{

-- r' 1.- :-*'r'+-;lit,,!a;ir-::..1ilt;:,.-:;.i:.f ,j;. l-: ,.,,.,-.)t.. '., ,. ..- 1 -' -.. ::::-:1:r-iE:i1,:.i:1:i:::-_:*t',:-r ..- .:..i:.-:::-::. h :.i: :

)
22 TRIBHUVAN UNIVERSITY Exam.
INSTITUTE OF ENGINEERING Level BE FullMuks 80
Examination Control Division Programme BCT
BEL,BEX,
Pass Marks 32
2055 Shrawan Year / Part vl Time 3 hrs.

I
/ Candidates are requhed to give their answers in their own words as far as practicable.
{ Auempt All.questions.
t Thefigures in the margin indicate Full Marlis.
r' Assumb suitable data if necessary.

1. a) Iilfhyis C programming most commoqly used in simulation? Do you agree that the
compilercan produce the executable file directly itself? Elaborate your .[2+2]answer.
b) Write an algorithm and a flowchart to read a five digit number and check whether the
I.- number is a palindrome or not. B+21

.2. a) List different operators with their corresponding associativity in C. Mention the size
and range of signed long int and float. [2+l]
b) Write an interactive progrun that readi positive numbers until user enters "no" and
then sum the numbers divisible by 4 that lie between the range of 10 and 50 and
frnally display the count and the average value. I51
3; a) IllusEate the formatted VO sking data. Why don't good' programmers prefer
goto-statement? Compare switch over else if-ladder. [+1+l] .
E
b) Write a program using recnrsion to comlute the sum of the followind ieries: tsl
12 -22 + 32 - 42 ..... + (-1)*' n2 without using pow( ) function. You should read the
value of n from the user.
4. a) How does a function optimize resources at the progranrmer and thq machine side?
How does a fr:nction retum value? Illustratewith example. : [+2]
b) Write a program to read number and call a function till 'yes' is entered by the user.
You should count and sum the numbers using static variables in the function and
return the ?verage to the main fuuction._ ,, t5l
5. a) Compare'array with pointer sptactically and physically. t2]
.b) Write to compute the deterrrinant of a square matrix of nth order and then
a program
check whether the given mgtrix is singular or not. You need to have two frmctions as

r::
t- -. read ( ) andprocess'-(-:'
-' '-,. ). '- , [6t - 1..
I --'
I.'.,:,
6. a) \Mhy do we need IIMA? Explain the significance of calloc( ) with example. [1+i]
b) Write a pro$am that reads positive integer nrunbers into an aray dyna:nically and
pass them to a function where odd nudrbers are filtered into another array and disptay
the array containing odd numbers in the main functiou. l6l
7. a) Mention the applications of pointer. Illustrate the invalid and valid pointer arithmetic
on both data variable and pointer variable. ll+11
b) Write a program that dynamically allocates twb different strings and pass them to a
function where the second sh'ing is compared with the reverse of the first string on the
chanicter basis and display the message in the main function. You are'not allowed to
u1e.!he sting functions. t61

-8. a) 'Illushate the self referential sbucture and the position pointer. ''': ,F+tl

I b) Write a prograur that illustrates passing function address to other functions directly
and using Pointer. l6l
9. a) Sketch the bits assignment in a stuctue if.you have 7 bit fields of 5 bits length each.
Justify the bytes consumption by above stnrcturc with reasoning. t2l
b) Write a progrurm to compute any two instant memory spaces in a format (Kilobytes:
Bytes: Bits) using stnrcture. Build functions to add and subkact given memory spaces
- where 1I(B : 1024 B and 1B=8 bits and dispiay the results in the main functien. t6l
TT!

b) Write a program that first appends the customer records ia a binary file and display
the number of customer records as well as the contents from the file. The file name
should be given by user and display if it does not exit. l6]
i

I
I
I
I
I

-1
I
I

You might also like