[go: up one dir, main page]

0% found this document useful (0 votes)
14 views7 pages

Assignment 4

The document provides an overview of various functions in the C programming language, including string manipulation functions like strlen and strcpy, user-defined functions, and recursion. It explains the differences between call by value and call by reference, and includes examples of programming tasks such as reversing a number and performing basic arithmetic operations. Additionally, it discusses the characteristics of functions with different types of arguments and return values.

Uploaded by

premparab26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

Assignment 4

The document provides an overview of various functions in the C programming language, including string manipulation functions like strlen and strcpy, user-defined functions, and recursion. It explains the differences between call by value and call by reference, and includes examples of programming tasks such as reversing a number and performing basic arithmetic operations. Additionally, it discusses the characteristics of functions with different types of arguments and return values.

Uploaded by

premparab26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Date

Page

Msigmed4
6tYCy ) function
Jtxplain srlen C) and
Nith example
a function in Cprogyo.
TH
Stylen): It j5 U6d To fiha
mmina language that 5
lof a otring It retuns.
the (Ûngth
nUmber lof chaYactevs
noll chavactex(\o
uding the include
# <6tdio: h
atring hz
chay ch 20|= h string: d d
pxint of th 0:
CLeogthretorn
5tvlen (co

6t ycpy c)? It 5 aafunction in Cproqram


Ián guag, that 15 062d to coDy dn
6txina to andthey T takes two ataum
nt5 the des tingt ion otrin4. aod thd s00
rce string
Exm. jncod? <5tdio-h>
# nclude <ot ring- h
alassmate
Date
Page

char ch (20]=ho10
char che (20
5trcpy (Ch2 ch
print INalu of 6eCond strina.:/5"chK
stuxn0
2\Explain Vser defined function Nith example
An' dentifiey 15 a u5eY -defined name of
an etity to deotify t uniducly during the
pxogYam execution
RxoMnple:
gt max K6
char Gtudeat name Bo:
Here marks aod gtudet name are identi
fiers.

3) Write aproqram to YyeY6e the numbey


1234
tt include <5tio-h
NOid reyerSe Num int anar int siza
int temp
temp

tem) arY C:
arr size -i-1ter

int main C)
CIASSMAte
Date
Page

int Oonber 6 C]=2,3,


int size=SZe of (oumbe51ze of
Caumber o);
for (iot o: i<6i2e5tt

print f (M
Yeverse Num coUmbex 5 51ze
print f ReverTd numbers
Por Gint ieo: i< 5ize itt)

prigt (n

A List the coteaoritó of fundixn5 and cxp


loin any on2Nith examole
OFon ctions ith no aYaoments gnd n0 Yet
2 Function with aYOUmeo5 and n0
3fun ction with nd aqumnt5 and yeton yalue
yalue retorn
Afunction
Value
wrth aYqument
aYgumeat Qnd
and retuxo
x
cssate
Date
Poge

AFuoction with n0 arquments ond ng retuYO


NQloe
This cateaory of fundion cannot Yeturn
hny vale Bat ToTo the
the calling.
calling pYO4raM ond.
it close ngt acceot any avake oro.
Exm:
Void
int
a-5
a,b,
b=6i
C=at
gPrint
It 6hould be call ed as add c)
5 Dist ioguish hetweeo cal by volue and cal
by erel
Call by valoe Cal)l by reference
Acopy of the valoe 5 )An address of valye i
Das5d into the tuntion passcd into the fontion
made inside tbe
2Chanacs made inside the 2changcs validate
fundon i5 limited to 1hc function ou
side ofHhe function
Aynction only al60
Date
( Page

The values of
8 The value of the acto- 3 paxameYS do
a paramcte rs do Agt by changing the Chanaes
foreoa
00YoneTe
change by changing Dararkerers
the fdrmdt povoeTe
formnal axa- Actual ond toxma ovo
HAual 00d at ments are cYeated
uments are created the 5ome mmory loc-
the diffxent meno vy ation oiy
Iocotio0:

6 rite a prooxorn t0 0erform additionsubt


racion. mulinliation ond divisio0 of two
ioteqeY Q0mbey vsi04, fun(tion
7# iclude <5dio-h
inclode<conioh
Noid add Gnt xity
e pYint f(ln odà ition= 0Xt)
VOcd 6ub int ninty)

No1à multi in t intyinty]


print tf(C In Multiplication = dX
VOd div nt X, intty
lassnate
Date
Page

majn

pxint f ("Eotey y
5can ( ddy)
5ub
mut
diy C
getch
Exolaio reCoYSion with exormple
RecuYiOn mean a functioo calls tself
xepetitiyely A_ YeCUYS0yC tontion cotain5
a fynction' callto it5¢f inside t5 body

indyde <6td io-h


# jnclude < conioh
Int factorial in tN)
Void main
cASSMAte
Date
Paqe

Int N fa
cIrscy0:
pxint f (Enterlnmhexo:
5Can -f ( c N:
fact =4act oxidl N
pxint ( ofactoYiól 15 kd; for
4cth ()
int factokiol nt N
if (N =
e \se
CN* foctoral (NI)

AdNOCtagc5
-Reduces lenath of the pro aram
Redr ces y0deces5aYy calhot ofa fun
lctioootias

You might also like