0% found this document useful (0 votes)
2 views14 pages

C++ writeup

The document outlines various programming exercises aimed at teaching basic programming concepts, including calculating the sum of three numbers, finding the largest of three numbers, reversing a number, and summing the digits of a number. Each exercise includes an algorithm and sample code in C++. The content is intended for educational use and demonstrates fundamental programming techniques.

Uploaded by

parvsatra28
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)
2 views14 pages

C++ writeup

The document outlines various programming exercises aimed at teaching basic programming concepts, including calculating the sum of three numbers, finding the largest of three numbers, reversing a number, and summing the digits of a number. Each exercise includes an algorithm and sample code in C++. The content is intended for educational use and demonstrates fundamental programming techniques.

Uploaded by

parvsatra28
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/ 14

Pracieal1

Aim Wite Ctt prosram to Sum and


three numbers

Al gori Phinn

Sturt
)Ddore three voncble marks 1 matks 2 , marks 3
to store
inputNan able
| ) Oeclare t o stonng
Sum
)Take the inputrom USeY Cinss
the values
|6) Caleuate he Sum and store Sum van able
Sum = mats marks2 ‘ marks3

Conpute Sum 3 :
) Diaplag the Coutk

FOR EDUCATIONAL USE


Sundaram
Code.

includ<iastream.h

int maun 0

doe mats morks 2


doble Sum av4

(out<<" Enter the norks


Cinsmarks > marks2 marksj

marks1 + marks2 t morks 3

coutkl" Sum <Ksun <endl;

heturn

unharam FOR EDUCATIONAL USE


Psactcal 2

Aim Wrile pogram to


three numbers

Algorithum:
1 Start
2) clave Vari aole
) b, C
tmee
to etore values
itegur
) Declore vaiablee largpst to 6tore he
value
Iargat input he USer and strc
them in variable
4he yales Condiion al opurar
Coopore ladder.
weing
else-
Ca s a>c) largat
Set
else

to Screern

Sundaram FOREDUCATIONAL USE


3
Cod e

|#incdude (iostreom h)
ocude <conio b

int main )

lrscr)

int

Cout<" ote three numbus

largat

loraat
else

Iagat

Sundaram
Cout P

lorgat numbe

etun
Pracieal

Aim Ctt to

qactomal nu m bey

Algavithanm
A Start
2) eclare C
Variable in t named a n
tb store he input number:
l3 Ded are vOriasle int
\an ab le
stenert &
\actonal and ini alise it ith
Tave the input Store it

oheruise tu
multgyYacton al

ndaram
FOR EDUCATIONAL USE
\otom
al
ial facko
nmbey Enter Coot«"
octril long
int
n
C; clrsr
C)main
<conio:
h> clude in
<iastream
h) Hinclo
de
Ctt Code
<nk's?"<|octori al;
Cool << " tocto a

Setun
Ainn Wrte to ueverse
number

Agonm

2) Dclare the Vaniabe int to take


USer
in put
Deelove vanable hem Hev intalise

)Take store it
input
NCAriade
whlie hot to

while (nl )
Catroct he last digt
Hem

) Arpend to
Campotg
) Rem ove he last

he Heversed numbe
to) Return CAecuthon

Sundaram) FOR EDUCATIONAL USE


Cade Ctt

tinode <iastrco m. h)
nclde Kconieh)

nt

drserl))
int
1
Cout < " Enter
Cin ny

n n /o,

Cout " Revecsed Numbey


PrackcalL S
Aim Wnle Ctt prgram to Surn

funton

Algorthn
Start

funethon Bum o Digts (intn) and


that takee an inteqer as inpet
3) Declove Vanable
a while to iterate unil
tract Last digi (ast n |"
ndd Last to Sunn

last

) Rern the
main
inal
nethed
yeloe
int mainc)
) Dedare Int n

Ceut
Cout <K"
2)Petun
Code Ctt

tinclude <iostrean h>


#include onio h)

int
GumOf Digts (int n)

int Sum

while (alo)
int |ast
Sun t laut

Sym

int maunC)

clrsurO,
iat

Heturn

FOR EDUCATIONAL USE


Pracieal

Alm Write
demonstte funton orloudin
Apntim
ad d Ctot nt b)
qunction
5) Take integre parametes
3) Compute ther Sum and
prins the

Deine an oten funethon peyametrs


double
add docble a double b)

Compote
nethod
) Ca odd Co ) to iot
uhich match doule
4) Return edccoin

Sundaram FOR EDUCATIONAL USE


Code in

rncde Kiostre am h
inlude < conio

ad d Ciot a ,int

Cout Su <(anb)

oid add double dosble b

<< Cab);

int main C)

add loi1)
adcd (s-3 i6 ) ;

getch C);
eetun

JCATIONAL USE

You might also like