Cse 109 (2020)
Cse 109 (2020)
SECTION-A
Question-1 (Compulsory) 15
and find its sum.
a. Write a print the following series upto n
C code to
[You must use for loop]
+33-44 ..n^n= sum
11-2^2+3^3-4^4....nn=sum
b. Explain with example the need of having different basic data types
in C programming.
in 8
C code to calculate and print the length of each word
a
c. Write a
sentence. Take input of the sentence from user.
Why?
#include <stdio.h>
voidmain(){
int i= 1
ifi-0)
printf("i is equal to On");
clse
printi"i is not cqual to Oln";
Question-2
a. In the Gregorian calendar, years that are multiples of 4 are leap 15
to this rule occurs on century years. A
years. However, exception
century year is a multiple of 100. Such a year is deemed as leap year
only if it is multiple of 400. Write a program that takes a year as
input and prints "Leap Year" if the year is a leap year. Otherwise it
should print "Not a leap year". [You must use switch case for this
question]
Input: 5
number
Output: Not amazing
and "continue' statenmet
ent in a
c. What is the principle of "break loop
Determine it.
Question-3
You are given 100 positive
integers as input. All these mumbers
100. Find out the numbers in the range of1
.
in the range of 1 to
in the input.
100 that are missing
Subject: CSE109,ComputerProgramming
Full Marks: 180
.00 hours
Section B: 90
B : 1.00 hour
UCTIONS:
Use SEPARATE
answer scripts for each section.
Question-5 and Question
-8 (Viva Voce) in Section B are compulsory.
Q.6&0-7).
Answer any OTHER ONE question fromthis section (From
indicate full marks.
Figures in the margin
reaSonable data if necessary.
Assume
used have their usual meanings
Symbols
SECTION-B
stion-5 (Compulsory) 12
employees of a company. The
program
a Write a program to manage
functionalities:
will have the following members emp_name
class with private
i. An "Employee"
emp_salary, work_hour_perDay. of the
function "set_info" to set inforhation
ii. A public member
employees. "show_info" to print the
member function
ii. A protected
information of the employees. adds $20
member function "Add salary" whích the last
iv. A protected works per day more than
Here, m
Consider a text
file named
b. marks:
within quotation
written below is n andr'
and roll number
My name
tasks: of
Now, do the following I with last
2 digits your
with your full name, in
i. Replace n modifications,
write the sentence
number. After these
roll
and
your answer scrip
the text file using getc( )
which will read
ii. Write a code in the console:
following output
will show the
My name is n
your full
name
Here, n
Example: Output in Console
is Afña
Data in ece.txtroll number is | My name
name and
My the 12
Afia and 70 in our program? Describe
can use
left shift operator
How we
c. shift operator.
of using left
applications 12
take a decimal
number as user input
Question-6 which will You
Write a C program number
corresponding binary
to print it.
it into
and will convert the
conversion.
function to do
must use a
f ö l l o w i n g
the #include<stdio.h>
Consider
b. #include<string.h>
struct
Shapes(
5 int helght;
6truct RectangleR
9 s t r u c tr a n g l e
ORINGbase
11 T
13
2 voldset_data(int h) Question-.
14
15 helght=h;
6
17
18
19struct Rectande e
i n twidth
20
21
23 Int main
24
structShapes S;
26 S.setdata(4);
S.R.base5
0
**
Question-7
indude <stdlo.h
2 Intmain0
3 45.29.8,6.5,2.3,4.5,
3.3,1.2,2.21
X[10]1112 33.1
4 foat
foatp1 &x4]
foat p2 pi 13
(p2)-7
foatp3 8p2
printf(%.2fn p1) .
printf(%.2An, p2)
intkp3
printf(%d"abs((double )02-(double )o1)+k)
13 return 3
14 ':
proper solution.
Page 2 of 3
b. Despite having malloc( ) to allocate memory dynamically, why we
need calloc() also?