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

Fop

The document explains conditional branching in programming, detailing how control statements execute code blocks based on certain conditions being true or false. It includes examples of 'if', 'else if', and 'else' statements, as well as switch-case constructs. Additionally, it covers memory allocation functions such as malloc, calloc, and realloc, highlighting their syntax and usage in C programming.

Uploaded by

neerajsinghbyali
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)
5 views

Fop

The document explains conditional branching in programming, detailing how control statements execute code blocks based on certain conditions being true or false. It includes examples of 'if', 'else if', and 'else' statements, as well as switch-case constructs. Additionally, it covers memory allocation functions such as malloc, calloc, and realloc, highlighting their syntax and usage in C programming.

Uploaded by

neerajsinghbyali
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/ 9

Q) Explain Conditonal bramcig amd its type unth

Cxauple.
Boramcing Stakmat is
ia i -
Those lauquoge statmeats iu Clauguaye hals aaproga
-mwey to co ubro tue
accordig to the negytremeut'.
) Couditiouad bramchingt
2) lu cond'tonal bramthing
Conditional bra
* s Depeuding on wh vale e ekpreston'true'
orfalse t ronstoms t Coutrol to a patiatan
8tatmeut
Ex;- i) H statmaut (í) 14 else statewat
i4(Cond' kon)¬
Dstakuent to exede |Block ofco de to be
exe citee the Coudito
ll i! Covndition is true is true

Proqani
i4 (20 18){ lblock Cod to be
prtat f"20 ty qneattlh
tham s')

Progom
3ttim 20 )
i4 (flmd <t8o)
pritf(" Gpod. dan ");
if Coditton) {
IIblot od Code to be. executd if Coudonl is thug
3 else if (ondiion 2)
Ilbloct q tode to be. exe cutud tf Coudi fonk &1 s ate
Qnd Co hdi tion 2 is tru.

I block of Code. to be ereitud f the Conditontis fase


Couditon 2 is aso fake.

Fogami
Rt t 22

pritf ("God Mor aug !"2


prtatf ("gpod day");
Stteh Stakunt i Syudaat Eraple
Suwitelh (ex presfion )$ break
Casex Case2
break
þrit f(Tuwsdas
break
Case 3
block.
break)
break aseu:
de<alt,
1| Code block breale
brak. ase s
pretf
break;
("priday ");
EKample aseb
ut aay H) prrtf ("ahuday"
break
Case I
break
("/n þrtutf
an)); (", þriutf
in~t+)1 (i=0; for
dlukta a<ku("Arrat prtfat
else
faied
n deate posit tnvalid Priutf
(t"
zh)i pos <ell (pos if
');todelek elemeut the posihon Eutnt þritf
l"
Cj)) a91 4 C%
d SCanf
i<n;ftt){ -0j (iat for
'n);
elemutsln dEutun þriutf
l'
) n it
<Stdio.h facue
nay aneletut
of the daldt þromam
to aC wtt 2)
a3) Wre the dikonce blw a by value ana alby
with Suitable exauple.
Call by Value :
The all by valus. method of paag gmeut to fuchon
optes tue. actial Valua efan angnet iato a forud
formal
paramten ofthu functow.
tucud. <stdio. hs
Void squane (int* n;
t man ()f

Squane. (nuwnben
þriutf ("n ts :' dIn ".humbe
þríutf ("nis : 7d \n',nmn),
9ehnn9;
Void baane Ciatn){
n ntn

Call by teonente i
gumat to
The Call by ne<ounte method hf pailg aguu
a fuuch'on. copieA tie adde o< an argumu iuto fomal.
ponamln Tside tthe fuuahone
aCles e acha!
made to panomtn ateet tu pasea anqumt.
clangsinoe <Stdio,hs
Void Bqau. Cint n)

prlut f(" nis d Yd tn"",hmber);


Saua Cumbe)
þritf ("n tsi/.d lnhaibey );
hetne

Void Syuw (iut * n)i


n nn

QA) What is aay of strucu Qxplain th an


aud proguon
Souton' Aray o!of sruchuu a. cis dlted
defied as Coletron o
wulhips stru'chues vaniablus whiu each vasable. Coutan
tformatfon about d'eneut eut aes,
tincud<stdio.h>
#include <Shig oh>

Cha name CioJ


poat salo
int main Ui
int
struteloy EmpEsJ
prtat f (ueuth Hae Re Cord of S mpleye)
for (i20, (<s, itt)
printt (" néuty (D "))
priutf ("\n &aton hat ")

britfl"n Eutn Salang : 93


In &tuet
Emplayeormatton g-")
for li0 ;iss,tt
priut t (" \n hame. &." CrJ hame:

quput
Butn Peordef
Eten 1D 00
euteNane

Name lo booo

butput
Euten Reordh of 5 Smp loyes
& D :000
&uter Nane! &poye l
Buten Salay
ERgloye lnformahiou h't.

Name! Eupoye
Salayi00 000,0 o o0
mewory allo otiem fmetion wi th erample.
AUoCatont Ihi~a proceM Cowmpitn
progmamnighaemus y halo (aed tduollo ctud
Aiy tltcoted
pre-io, exeuhbn a progam , athun the berg
to
uo Cot teory based on tt actuol gguremt a
lun'm male'g tore fluxibet ueut.
The DMA fuuctoh an
ú) MallocE)
’ The malloe fumehion s used to alloat aspi fed wmbon

Syutax Void *malloa CBi 2 .t bie)i

tt jucudi <stio, h>


tt iucld cStdteb.h>
int main ()s

itneS}
n;
allo atenfailed
printf
rehhn

free. Can;
rehne
Glloc:
The Calloc (ontiugus allootorn) fuueton is usd to allotat
a specild wiwnber blocka eaory h aspeu'fiec
Squtan - void callo c (siret nem elemats.
Bize- t eleut sie)
#includ <stdo.h>

itmain 0
t Ka
(ut n s
an Cut ) eloc (n,sze Ciu))
îf(aM 2NULL)
prutf CMemory allo otan faied n';

freo Cay);
rehn0j

( ) Reloe:
-> The ihealoo' (n eallocat mevory) fueh'on s ued
þrevioutey allo Catud tocleng
Syuta vord tealloe. Cvoid t sitet bize))

#ineude, kstdio,h?

jut n2
ant

prut f (u Menory aocah'an faia


ehun 1
n");
n=10:
ann (itt reallo (an n size o FCut
priutfleMeo
nehn

free Can);
rehu

The free' fuu ch'en ts wsed toalloat manmory that ual


prevtouty ollocotad ws tug mallec Galloe,oooc
Syutax

You might also like