Scan 13 Jun 24 16 30 08

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

in c

fuoqsammlng
tormat comm
lohat are the d}er rent data
types Ey

math
Specihiens in c2
dy pe > Struct, Union, etc
User de ined data
doays. Fun ions, Pointe.
Deriv ed data ty foat
Built in char,
data Vord, int,
db
TOTmat Sperts-

operentat e conditiemal perato wifh if else

The conditional Operator i8 a 8ingle

statement and Can ony pefom Con


programmiog
ODe operaion else is a block gtate ment Ca
bence it can qroup mutiple cstatemen

senga paranthes is. The condItion al operator


Can Yeturn
a vaue and so Can be used

torpefoIming asignment opeah'ons

3ist ut Nodigcexs
Signed| Unigned
Lor
ort Integerá
Modifers.

4compare keyuoord with library funchen.


ykeyuwords are reserved coords in a proqrammi

Sanguage that have a predefined meaning


They cannot be used as identif'ers.

Library functi ons are pre- written tunchiona


provided by the Lanquagek standard ubrary
lor addittenal ubrartes. They pertorm specie
tos ka that are
common in progiammung
aYe sed to define the strucure
Keywords
and foeD a program

St. John's Public School


SJPS
. Use

an alternate
type def key
The key
cword
word ty pedef is
uL ed to defhe

an already eishing
name tor

data type uSer dehned data


ts mastty used for

type

Command une arqument:


that are given on
e

dre simple parametes


ine, e he values these
thesystem's command
to the.program
arquments are passed on
duiring program execuhion. when
a program
en,
otthout user interacti
Startd executien
cOmmand - ine arquments are used to pass
vatues or iles to

Various 5 modes
Y- Open a le in read mode
create text file in orite mode
W- open S or a

a- Dpens a file append mode


in

Yt- Opens a file tn both read and write


mode
at opens a le in) 1)

u Ddentifhers )Give Exampk


Tdenhfiers dre the names assined to diiferent
lentiti such as
es Variabl es, tunch'ons, arrays, etc

Ex: int gcore = q0 Ih ;


sthis case,8core' i8 an

ldentit er that We've used to name Or inteqer


Variable.

SJPS St. John's Public School


OFetence blo drgumenta & Para mtes
Parameters
7 when drqument
a tunc is called The values whlch are deine!
the Values thatrpassed at the tIme of the fundhon
during the call are prototype or dephitin e
catled the funchion is Calla fara

They are dlso catled Forrnal Parameer,


atual Parameters

Ex: Int num:20) int call (int rnum)


cail Cnum)
printf (the numis T.d
Ynum

4. Toportan ce Of ponter
Pointer allow us to manpulotethe.
data uin computers
cthe memory
Pointer_can redute the code and
fnprove the performan e
They are important for dynamic
memory altocati on , passing argumenta to
unchions, cworkinq with amays

loile Pos ttien

The File positton s an integer representing


dhe number og byte from the beginning
the tle
Sub The fle posthion is notmaly set to the

beginning
and each tme
the
a
sile twhenit
character ig tead o
s
cpened,.

DTi tten, the file poaition f8 încremented.

St. John's Public School


SJPS
IOhat aYe the fomated inptl autpu!
various
:
formated
The moastcommonly used
ction fA & CanfO,
ohich reada
nput tun
or 2Lternal gource
unput rom the user
spechers
based "on specgred format
80

he pint () func s used for formatted


70 clsplay
Cutput atlo aotng the proqram
data ti a dlestred tormat

l6Compute drray gize, (eng fh or yven aay

eine Recursive function.


Recurgton in c is a pro cess uwhere a

tunctiem cals tseg to sove a problemDE


to be broken
allousa compley problem

down nto &impler &ub -proble ma, each g

ohch s solved by invoing the same


functien

18
Dynamic Hemory allocatron is the

proces q asigning the memorg space cluring


the execution time or the run time

di gunc Used to alib.ate memony dyncna

reac)

19.Oi buMode orite


dppend Hode
The write mode areates
dppend mode ta used tb

a Deco hle.
add the deta at end e

tle ithe fle akeady at

St. John's Public School


SJPS
credtes a
the) le
ls alkeady
7 Other wise
neo one
edsting write m ode
Ofher oYerwri tes it

aoQine Unien.
Gs user- defined a
defined
nton can be a collect'on of ditferent
data type which ig in the
8o me
Variables different data types

mermory ocation

otgit Extra ction '- CProgram>


# fncude < stdio. h>
int main )
f int numbel, digt i
print} "Enter an enteger:
Scan ( Zd 2 number)
I cnumber <o) ?
number= -umber
In");
froro right to lett

.
printf ("Diqits
do
digtt =number I0
printf ("/. digt),
d In",

nurmbere number 10j


} uhite (number zo),
return o

oP Enter an integer: 234S


Dqcta frorm T1

SIPS St John's Public School


used to perform
* ibrary unctions are
loutput operatiors
common tasks wke input
olata manputanen
mathematiaal Com putations.,
etc
syntat
Tnteq ral Part af the language
Not part of the core lang uage syntax
dbut aYe provided thrO ugh
libraries

5 Muti dm ensenal daay


m anag ement
t
allows for the storage
and
cway The m O8t
Of data in a more structured

common form ts two - dlmens UEnal a cwhich aIay,


Can be visuaixed as a matnz
o taule a
th 9Ows and cplumns

eoternal &torage.
t is pecifi'ed gott by the extern keycuord,
isused to dedlare a Naria ble that delned in

another fle or in a dilere nt sCope uthn


the

same ile. This storage dlass allows for the sharing


lo variables mutiple fles, enabling beter
acroSS

modulcity dn Code org anizah and acesed n


any tile that indludes its dleclarahen.
from

7 014eren ce blu 8tYucture6 Unu'an

8TRUCTURE UNION

The keyword etuct is used to Unionn 12

detne a gttuctue
7Each Hember withina &trucute Hernory allaated ie shared

is a.siqned uhigue gtorage by indlividual mernbersqf


area o (ocation union

)Dodtvidual mernber can be hly ohe member can


accessed at a time be acaeated at a ime.

SJPS St.John's Public School


b. (i) Write a note on reading a string from console using formatted and
12.

un-formatted functionswith an example program. (6)

(ii) Write a C program to display the sum of diagonal matrix of 4x4

integerarray. (7)

and return type with suitable


13. a. Explain function types based on arguments
examples. (13)

(OR)
Write a recursive function to sum the given n-digit number. (4)
13. b. ()
(ii) Write a recursive function to count the digits of a number. (4)

(ii) Create a user defined function to returnthe sum of an integer array


to invoke the
passed as parameter. Write a driver main function
user defined function. (5)

14. a. Explain structure and array of structures with example. (13)

(OR)
14. b. Explain about dynamic memory allocation and its methods with
(13)

)
examples.

15. a. Explain the operations and functions that can be performed on a


(6)
file.

(ii) Explain how to read and write a file using fscanf) and fprintf)
function. (7)

(OR)
arguments with suitable example. (6)
15. b. (i) Explain command line

and rewind() functions with suitable


(ii) Explain fseek), ftell)
(7)
examples.

PART -C(1×15 = 15 marks)

16. a. In acollege, assessment marks for a subjectis entered for students. The N
program must accept N
studentsmarks and print the total number of
studentspassed, failed and absent.
Constraints for evaluation:
(A) The mark forabsentee studentswill be entered as -1.
(B)The pass mark for the studentshould be greaterthan or equal to 40
(marks less than 40 is considered fail)
Create the following user defined functions:
intn)
intget_absent_count(int array[],
int get_pass_count(int array[],intn)
int get _fail_count(int array[],int n)

Sample input:
First line: 10 (Number of students)
B.E/B.Tech. DEGREE EXAMINATIONS, APRIL / MAY 2023.
Second Semester

Computer Science and Engineering


(Common to Electrical and Electronics Engineering, Electronics and Communication

Engineering, Information Technology)


22CS291 –PROGRAMMING IN C

(Regulation 2022)
Time: Three hours
Maximum:100 marks
Answer ALL questions.

PART - A (10x2 =20 marks)


1. What is an Identifier? Give an example.
2. Write a note on Formatted I/O functions with
example.
3. How can we compute array size and
array length? Give an example.
4. What is a String? Give syntax and example for using a String.
5. Define recursion.

6. Give the use of register storage class.


7. Enumerate the use of pointers.

8. What is dynamic memory allocation?


9. Classify append mode and write mode of a file.
10. Define a sequential access file.

PART -B(5x13 =65 marks)


11. a. List and explain about the decision making
statements in C with suitable
example.
(13)
(OR)
11. b. Define Looping Statement. Describe the different kinds of looping
statements in C with example.
(13)

12. a. Explain array and its types with syntax and example.
(13)
(OR)
line: 56 23 -128 78 89 64 53 -196 (marks)
Second
Sample output:
No. of students passed: 6
No. of students failed: 2
(15)
No. of students absent: 2

(OR)
waiters available, there comesN family
one by
16. b. In a restaurant there are M

each family gave tips to the waiter


one served by each waiter one by one,
number of families
who served them, write a program to compute the
served by each waiter and total tips amount.
Example:
M=3// there 3 waiters
N= 10 Il there come 13 families one by one
Tips given
15 10 15 10 20 30 15 2520 20
waiters served in the order,

wl > f1(15),f4(10),f7(15),f10(20)
w2 -> f2(10),f5(20),f8(25)
w3 -> f3(15),f6(30),f9(20)
total family served by 4 and tips amount is 15+10+15+20 =60
wl is

total family served by w2 is 3 and tips amount is 10+20+25 =55

total family served by w3 is 3 and tips amount is 15+30+20 =65 (15)

You might also like