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

Assignment 2

The document contains programming concepts and examples, including flowcharts, algorithms, and syntax for various programming constructs like loops and conditionals. It discusses how to declare variables, perform arithmetic operations, and utilize functions in C programming. Additionally, it includes examples of checking for prime numbers and calculating total marks and percentages.

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)
8 views

Assignment 2

The document contains programming concepts and examples, including flowcharts, algorithms, and syntax for various programming constructs like loops and conditionals. It discusses how to declare variables, perform arithmetic operations, and utilize functions in C programming. Additionally, it includes examples of checking for prime numbers and calculating total marks and percentages.

Uploaded by

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

classmate

Date
Poge

ohscigmt-2
2 marka quustans
1 Drawr and lalel sypbela uaud in Jau chart.
1

lam
Proces
Iapot out pot.
Dcision
Conncctor

Prcde fined
pro ccss

Terminal
Flo Lincs.

2Dyfn cdlyoilhm
Date
Page

leuchast:
Start

Declare yariables num1, nur


and Gum

Readoum 1 and nu

Add oum 1, num 2 and assign


yalbe to som
Sum = pum 4 + num 2

print

Stop
h whill loop in Cis ud to ualuot a
hat candlion and iterat
bsdy until thu condition iluLnA du
cAssMAte
Date
Poge

Synta of while losp


iniialization
ohile C condition cpression)
block of statcment
inrement |decrement

Syntax of if-clse ladder i


i4 (oxpression 1)
statemcnt i

clse if lcxpression 2)
Statcmcat i
3
clse if (cxprcssion 3)
statcmcnt i
3

lse

statcment s
3
lssMate
Date
Poge

6 dlal any dfaunea lun uhill ad deuhl

Lhile
Lnly canballd conalld logp
2 o semicalan at
he thu nd of th do-ul
uhil anaition. Candiion
3.Jhe caondition 3.Jhe condihan statmu!
sttmndi ad i ad the nd o h
th luginning

1 19fine day uilh Ayntan

They are declarcd by qiucn synlax


Datatyhe array- namc |dimensions]
felement1, clement 2, element 4
Date
Page

4 marks qustiens
a lidean algoithn ta dilumin1 thu giuen nunlur it

Algorithm-t
step l : slart
step 2 (Take input) Rcad Number
Step 3 i check I Aumber t2 =0
Then print : Nis an cVCA nombcr
Else
Print : Nis an oddnumber.
step 4: Exit.

q Praur fleuchait for chisking ualhu qun numd


Flowchart &
Date
Page

Start

Lnput Num

Re sQRT (Nurn)
I2
Jrikc Oum iS Q prime
IF
Dumber.
IR

Write Om Ís not
prime oubec.

j= iti

Stop

1oDaw authaul
thy numbu
fa chuking lagut umles
cASSMAte
Date
Page

Start

Col, n2n3)
Read 3 numbers

Display n s
yes qrcatest

Display na is
qreatcst

Display ns lis
qreatest

Display all
are equal

stap
classate
Date
Poge.

Auitall LNAnpl
Print () is used to priat the output on thc
display
Scanf () funcion is Used to scan or store the

Something
#include <stdio.h
# incude < conio. hz
Void main ()

int ai
print f (" Entcr a numbcr") R
Scanf ("% a ) i
printf ( The number that you catered is eda):

.Eplain any faua Aluny functensndu conia.h


Libracy funcian are as follouaing
clrscr C) - This funcHon is DSed to clcar the
Dutput screca

qctoh C) - I rcads character from keybaard


qetch ()- I! rcads character from Kkeyboard
and cchoes to op Green.

putch () -Uritca a character directy to the consol


classnate
Date

Eapnlain anaditonal punter Laanpl.


Candktionalgrunado sulan on alu f sandtion
fale Thi puuatori alo alld
agumnt.
Gyatax
(condition ? trucvalue false valuc):

# include sstdio.h
# include <Conio..h
Void main )

int i
clr scr Oi
printf (" fnter a numbc")
Scan f(" hd",2i)
i 2 ==n? print f ("od js eVen ",)
print f " dis add", i)i
qctch O;

4 Eplain inctamund and setamund gpeado.


tacamnt spata is uudo incuasl thu salu ofa
aziakle ly_an. lia lguiualnt o adding on ta
h dcumunt gpato s ad t deuathu alue
pge

15

Keyuwsal
alhuadly knaun te hi canypila
iaDing uhich

duaiguslh duiag
ariale un nam_giuen toa mumeLy localion,
dalaty1 duing hu pogsam txLCution.

halde
Nution
anlyanL alu hueugbau th agam

hem uncaleulath and display lalal


and pucenlap a< sludad.
Proqran i
#include &stdioh
#include < conio.h
Void main ()
classmate
Date
Page

float macks [4]


float total = 0.0, per c = 0.03
int i
clarscr (0i
For (i - L;ie 4 ; 0++)

printf (" Entcr marks of subjcct d )


Scan f C F marks i)):

For ( i e i le 4 ; it+)
ftokal tokal +marks [il:4
printf(" Total is %F" total):
pce C- total l4 1
print{ (" perccntaqe is F" pcnc)i
qctch ()

You might also like