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

Assignment 3

The document discusses various programming concepts in C, including type casting, relational operators, keywords, and library functions. It also explains increment and decrement operators, bitwise operators, conditional operators, and provides examples of code snippets. Additionally, it outlines the general structure of a C program and includes sample programs for better understanding.

Uploaded by

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

Assignment 3

The document discusses various programming concepts in C, including type casting, relational operators, keywords, and library functions. It also explains increment and decrement operators, bitwise operators, conditional operators, and provides examples of code snippets. Additionally, it outlines the general structure of a C program and includes sample programs for better understanding.

Uploaded by

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

clasSMate

Date
Page

2 macks questions

Define type caatíng. Glue any one oncxample


lype caaling refere to changing varialaleof
One data type ioto another. The conmpiler coil
Lautomaticaly change one kype of data into
Lanotheri it make Sense for insBance ,if yau
Lassign on inteqer yalue to a floating - point
varialble,the compiler ll conuert thc int to fAloat.

Exasple
include <stdio.h
#include <(onio.h

Void matn()

int a.b,C 3
loat avqi
prtatf(Enter any thrce intagcr ualbcs")
banf (" d d l l a b . Re)i
Lavg - Cato tc)lsi
pinif ("aup before casling" En aug)i
clAsSMAte
Date
Page

Laug=(float) (atbtc)L>
printf ("aIg after casling 1. Fla,auq) s
Lqctch():

2Y State the Rclational opcrakDrs with cxample


Ia Cocelational opecators arc the symbole that
are scd for camparison bcth tusa valucs to
underatand the typc of rclaionehip a pair of
numaer shares The resol4 that oc qet after
the relatíonal operatoion s boolean value , hat
telle Lohe
ohe ther
ther the Camparison is truc or
falsc.
Exam ple : (4>3)

Sumbal Name
tqual to
Not cgual to
lees than
qrcater than
less than cqual to
qrcater than eaual to

Deecribe the follouing tcnms


Kayuoord.
KeyLo0rd are the rcecried orde uoith
prede fincd meaning ahich alrcady Knaonto the
ompiler.
Date
Page

’ The ideniftcr is a uScr -defined n0me of an


eniky to identify it uniquely during Hhe program
exccuion.
y Variable
-’ Varialdle fo anome aiven to a mcmory locaHon
where L0c can sBone difcrent yalucs of same dole
kypc
4 nlist clfercat fcronat speißers oith ius
Famat epcificr liype of output
or 1 i Adednaal ikcacr or signed

Signed characker.
%F
gned foat
Afloating point numcer.
Ashing a scucnceo
character
Double
LE Long doube
classmate
Date
Page

ockal intcqce
shot unslgncd inteqer

s) Lrnplem cnt a to demonetrate logical


AND opcralos pregram.

+include <stdio h
# íncude <conio. h
Vofd main )

inti
clrecr O3
príntf(" enter the valuce í andi)s

print! ("Both i andË are cqual)

oiotf(
printf(" Both the ualucs ate dilferent
and cither or boh are not cquat to 5"

qctch);
Date

Page

4mark QucstHona

the use of printf)scanf ) oith


y State
suitaalc CXamples
PrintfCO and sanfL) funcHons arc library
funcions in Cpregraranáng languagc defincd in
stdo.h
printf fncion fe uscd to_print the character
sting floatinteqer, octal and hexDdecimal
valucornto the output Sren

Scanf ) functon fs used to rcad charackec, slring.


Dunncric data from the keyboard. od Forrmat
spe cifiet ia ueed in print f() and scanf )
to speclfy the valuc of an inteqcr Variublc
Ex.
#inctude <stlo.h
t tncude <conio. h
vold main()

crscr ():
printf(Enter a numloc "):
sCanfhd', i);
printfEntered numb er is d
qetch)s
classMate
Date
Page

al Explain four liorary funckBons


>clrecr(): This funcion fs sed to closc thc
Output Screen
qctch) - II rcads the choracter from Keyboard.
Lqetche(-It rade the choracter from Keyboard.
and echoce tD
to op sreco
puk ch O- Wrtes a character dire cty to the
Console.

Explain increanment and decreament opcraBor.


Tncrcament cperator ia us cd to fncrease
the value of o uarialale oyTH is equiualent
too adding One to the variakc. eh The Gymbol
uscd is tt, The decrcament e operator is used
to decreasc the yalue of a varlalole oy LIt
io_cqulbalent to suBra cling one from tthe varialle.
The sumbol uscd ie

fre -increament opcrator


Pre -icreanent operaBor is uScd to increase
the yaluc Of yaridble los One bcfore ueing in the
Cxpression.
Syn tax : t t Varlable.
Post-incrcamcnt opeator
Rret of all the loop exCCutes. then valuc of
Ahe concer yariaale ia încrcment by l, and
rctun the valuc beforc present update sBate
Variaale t t
Date
Page

Prc -decrcmeat
Phc- de Cre ment operator is uscd to decrcase
the valuc of ariable bforc uslng in.
cAprcsson.

Post -de crcament


It fs uscd to decrease the yalvc of Uariable
fmmediately after excculing Capression
Completely.
4y Wrike a proqram to ccept marks o our eub<ccks.

#include stdio, h
# include <Lonio. h
Void main/)

Int aug l4)i toal -o


Aloat avCrage
drecr):

printf"Enter the marke);


Scanf(" d,avqLs
total - total t

printf ("otal is ted, total )3


Cueragc - Ctotal4);
print f ke average of Hmarks is eF
2 getch(O:QJeraqe)
clAssMAte
Date
Page

5) bxplain any four bit -uaise operator uoith cxamplce


lgpcs of bitalse opcrator arc as follos:
y ANO operator (2) The bituoise AND opcrator
performaa logical AND operator. on. cach pair of
Cortceponding oite. Ti rcturns Lif both bit
valucs arc iotheruoise t rcturne 0

) OR opcraBor () : The bikoiee OR 0R cpcraBor pcrjocms


a a
logical OR opcrakion on cach par of cottcaponding
bits. T rckurns if at least onc of the bit

) XDR opcrator¬^) Thc bitoise xOR Operator


rchns if the btskits bcing: comparcd
diferant otheruise it returns 0.

Ay Complerment operator (): The bituaise complement


opcrator inverts the bit valvee.

Example -
# include <stdlo. h
# include <conio. h=
Void main()

int a - | 2 b 25 ;
clrscr ():
printf(" oukput - edRalb)3
qctch()s
Date
Page

Explain Condiional operaBor olth cxample.


6 Condiional opcrators returna e value if COndio.
CondiH
is truc and reeurag anather ualue if
s falae This operaBor s also Called teman
opcrator as it takes threc arqumcnts

Gyntax -
(ondilicn )2 truc-valuc) lfalse vale))3
Example
# incude <stdio h
# Include <conio,h
Vold maln ()

clraur (:
prinh£( fnter the number"):,
5canf ( di)s
(it=-D)2 Cprintf( 1ed ís cueni)s
(peint ("dis oddi)s
qetch()s

y Describe qencric trucure of C program.


qeneriç ekacture
program
Date
Poge

Documentation SecHon
Link Sccion

Definition SecHon.
GlobalDccdarakion cction
main O FuncHon Scction

Decaraton part
3
Exccatable part
SubprogramSecton
Funchon l
funcion 2
func tion

un ci on n.

You might also like