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

Week 11

The document discusses using computational thinking concepts like data structures to help a pediatrician's assistant organize patient details. It defines a structure called Patient_Details to store information like patient ID, name, age, and complaint. The algorithm then prompts the user to enter the number of patients and loops to input each patient's details which are printed out.

Uploaded by

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

Week 11

The document discusses using computational thinking concepts like data structures to help a pediatrician's assistant organize patient details. It defines a structure called Patient_Details to store information like patient ID, name, age, and complaint. The algorithm then prompts the user to enter the number of patients and loops to input each patient's details which are printed out.

Uploaded by

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

cOMPUTATIONAL THINKING FOR STRUCTURED DESIC

Execution:
# n c l u d e <stdio»h>

Struct Student

age
char name [io

nt mooC)
student name, age
pintf C Entu

,a.age&a. name J
SCaf/ d s
priorf ( \n"
Student data:

printf("/.Jns ln ", a. aqe,


a.name)

vetun D

Test case Table:

Testcase# Testcase Type Input Expected Output after Testcase Result:


output Program Pass/Fail

RoM RAM RAM


0
20
20 Pam
VLeRAM VIKRAM
2 VIKgAM
94 24 Pam

Page 292 of
368
cOMPUTATIONALTHINKING FOR CTURED DESIGM
Algorithm

foclude <stdfo.h>

ttinclu de <sting.
ttfnclude math.hb>

inchude etoe
rgclode Kquenex

struct peuson
&hnet r

char name l ,
int Job
peson
n t maîn )

Sconf ("d", >n);


get chas
char job[is);
peson Ship{nJ
fol (int 1-0; fen;?++)
R
SCanf ( s s", ship[tJ.name, job);
getcharC),

F Strcaecmp Cfob, "Captatn") = 6)


ship 13 job = 4
elaei f (strcasecmp job, man) 2 = o)

ship (iJ job=3;


ele F (strcasecmp( job, "rat ") 0)
Shtp i3 job =1
els e

ship (3-ob: 1i/

Page 294 of 368


COMPUTATIONALTHINKING FOR
STRUCTURED DESIGN
int(1ot
a 1 O , o-1La
f<r af+)

a0
j++)
3=o; jen-I-i
eo (int
te (ship 3 . o b >sship lj+1]. job)

peLsonemp
memcpy(2temp shi'plj J, Stze of (pes tn) );
memcpy shipljJ, k Ship ijt1), size of (pess
on))
memcp y(shipljtil, k temp, size dt peson):

3
f fot =o,icn;it+)

li].ngme)
priot+ s \ o " , ship

table
Testcase
Testcase Type Input
Expected
Output after
Resut:Pass/Fail

output execution

JacuCapt Teddy Teddy Pa


Auceuorad Alice Aice
chaulie nan Bob Bob
Teddy rat Tulia Julia
eb chil chasle Chaxíe
Tack aek
Coan
cOMPUTATIONAL THINKING FOR
STRUCTURED
P
Time of the Session:
Date ofthe Session:/J _to
Problem 3:
he visits Ramesh Hospitals between 2pm to Bpm on weekday
of the city and
s

Dr. Kumar is the leading Pediatrician

and stores their


details and gives the list to Dr. Kumar wh. he arrivesat
His Assistant makes a list of the patients
assistant create a
structure named Patient_Details and and storo.
store the
the hospital. Your task is to help the followwing da
can be one ofthese:
fever, high fever, cold, cough
Complaint. Complaint sea.
Patient_ld, Name, age,

Sample Input & Output

Output
S. no Input

Algorithmn +Include <stdid, h


Struct Pattent- etails

Nong Sonq int Patient d


c'har nome l20J,
fnt Age sro
char Complatnt 1oJ;
aCioo
n t moen)

printf C Ente the no.Of patien ts


Scanf ( d", »n);
tCi = 1; iz=nj it+)

Compan-
pfotf ( enter patient durámt, , nge,
Sconf1+0d -). s /. n J s a l t]id ,&ofJ.name Aali

2aCi1.cmplaint ),
3

Page 296 of 368


COMPUTATIONAL THINKING FOR STRUCTURED DESIGN

Execution:

fe i13 i<: n ; i )

prfotf C"In wePollss /.d etotl


Patient

printf ("1Ud In:/-S \O :/din /S , a[1 ].?d, ofl.rnome, t1age,


afil. complaint ),

retuan 0

Test case Table:

Testcase# Testcase Type Input Expected Output after Testcase Result:


output Program Pass/Fail
to
3nTYA SATt
SATeA
Fevea FevER FEvee
Pa
S2ec
SREE SRee SS
55 sS CoLO
CDld
cOLD

(For Evaluator's use only)

COComment of the Evaluator (if Any) Evaluator's Observatio U Out


Marks Secured:

Full Name of the Evaluator:Evaluator's Observation

of the
Date of Signature
Sigratúre of the Evàluator
COMPUTATIONAL THINKING FOR STRUCTURED DESIGN
Execution

inctude <stdio.h>
Struct studert

chor Name (oJ,


floar ffrstueasmous, erond yens tnasks

3 sis3
int main ()

nt ,
print F" Entes name,
firntyea mais Serone yea mesks

fot(iz0: fL5, ++1)

S c a f( - s f-f 1 . f " , s(iJ.Name, 2 s [ 7 J . s f i s t yens m aues

&s7-secora ueas mask

printf ("in studenttddetols , 1)


PrinF C" 4 6f«t. f", sTi1.neme, s Tttrstueas aats,s cr
e a maauks

retun O
Test case Table:

Testcase# Testcase Type Input Expected Output after Testcase Result:


output Program Pass/fail
RAM
2AM PAM
889
93.2 32 13
v(Cky
2 VICEY VICEY
2.7 42. 72
I98.27.4 18

Page 299 of 368


cOMPUTATIONAL THINKING FOR STRUCTUREn
TURED DES
S IC
visited their place for.
Problem 2: of people who for the past
take a survey
wants to
A newly opened Mall
of the visitor
one month. Print the information

Web Link:
https://www.hackerrank.com/contests/beginners-in-c/challenges/dmas/problem

Sample Input & Output


Output
. no Input
Anne 24
1
Anne 24 Bishop 36

Bishop 366

Algorithmn
*nclude <stdio-h>
tnclude (srdlib.h
tt detne HAX 3

int stk [MAXJ;


int top --
void push (int add)

?4 top = = HAx-t)

printf (\n stock ts oveslow");


else

top ++
Stkltop]=Qdd

Veid dplay ()

E Cto p = -

)
printf (" \n stack s
ee
bpty")

print-\nDetoj a
( i top; 1-o1-)
Page 300 of 368
cOMPUTATIONAL THINKING FOR STRUCTURED DESIGN

Execution:

printf ( / d " , stk ( rJ);

int moain C)

char blioJ
nE chofce, add,
while C)
lo 3.Exdt ") :
pYnE ( In I. Push In 2.Dsplay
priorf C" In fntes yous choi ce:),
Sltch Cchof ce)

Case 1
Oge
prioTf ( Entes cAaie of vfsito
Scanf( .d ", Ladd )
push Cadd),
break
Case 2

dplay C;
brea
Cose 3
extCo)
3
retuun 0

Test case Table:

Testcase#Testcase Type Input Expected Output after Testcase Result:


output Program Pass/Fail

24 4

27
24,2 24,27 Pa

Page 301 of 368


cOMPUTATIONAL THINKING FOR ST

S IC
uCTURED D
Problem 3:
Passing Structure function arguments. The
as
whole structure
function
is passed to another.
another function by
value. This structure canbe accessed from called

Web Link:
h t t p s : / / w w w . h a c k e r r a n k . c o m / c o n t e s t s / b e g i n n e r s - i n - c / c h a l l e n g e s / s f a 0 0 1

Sample Input & Output

5.
Output
no Input

Algorithm

nclude <stdioh
tnclude <string.h>
Strue ooge

chor nanme [so];


int s

struct age cmplouee


int maincC)

Struch wage e,
ez employ)

Pritfttin woge details of the


employeen *)
printf name / s ", e.name);
printf C\nuoate; /d ", e.Ys)
retun 0,

Page 302 of 368


Execution:
COMPUTATIONAL THINKING FOR
STRUCTURED DESIGN
struct coase employee)

Struct e e
priotf C ente tthe name
ScanfC-s'", e name) mgloyee, ")
printf(1d",
Yetun e
aes S) ;

Table:

Testcase Type Input Expected Output after Testcase Result:


output
Programn Pass/Fail

2
oo Pan
Rorn Ram
SoO Pann
(For Valuator's use only)

Comment of the Evaluator (if Any)


Evaluator's ObservaionU
Marks Secured: _out of

Full Name of the Evaluator:

Signature of the Evaluator Date of Evaluation:

Page 30 of 368
STRUCTURED
DESIGN
THINKING FOR
COMPUTATIONAL

E x e c u t i o n :

i n c l u d e <stdlo.h>

Struct enam

nt rol,
tnt mart3
cha name l20J,

Structexm obf [23; 4


funCstruct
tom ob}
vofd shuet
struct fun
(struct eram* ob/)
vof d loj.rname.
/.s \O kollno fs: 7» d Mauki aa: /. d obf
\n
prfnt-f("n Name is:
oblo3.roll, obj [o3. mariks)

printf C*\n"); 7.d


\n ltno s: /d \n
Maubs aua
obf [iname
prfnte" n AMame?s 4s

obf fi3.roll, obj lJ.marks)

ot main ()

(ol.mailes, obf oJ.roll,


objloj. name)
scanf ( -d 1d 1 \ n J , &ob
S cant d/ d 7[^\n]", Aobj[tJ. mauks, objitj.rot, Aobjlj.name)
Structfun (obj )
Tetun d

Test case Table:

Expected Output after Testcase Result:


Testcase# Testcase Type Input
output Program Pass/Fail

Naime s; Bcdram Mae is Balle


evauar elau
Bdram
chauhan
Rellnost olln Pan
Maues au :63
T0 29 Mama is' Auin4A Maueis, Ra.uAu
Ravindra Jela
Joleja Rello 2 Rolns:

Page 305 of 368


cOMPUTATIONAL THINKING FOR STRUCTURED DESIGN
Execution:

tincdude <stdio» h>


Struct d09

cnau name ioJj


chaa bree& lan0)
nE aqe
cha ebo u Lo7,

3a
fot main)

pri(Gnte Dog. name, breed,age, colei: "


SCanf -(-s 1.S -d s " , aname, a.breed La 0g.colot
prinTf ("Dogs Data ");
pintf s s/'d /s ", Q.name, asbree,a.age, acoloy)
e uund

Test case Table:

Testcaset Testcase Type Expected Output after Testcase Result:


Input
output Program Pass/Fail
Spicy Sple Spite
Guldog

Phume Pme
o denReine Cpl elen Retaive
Ryhane
Gs Autiva Pos
GouD |GoLD

Page 307 of 368


COMPUTATIONAL THINKING FOR STRUCT
S IC
Time of the Session:_to
ICTURED DESIGA
Date of the Session: J
each box is

rafinite.al elepiped, and


where a
Problem 3: a tunnel,
D:

some boxes through


You are transporting
and height. infi.n
characterized its length, width
by width can be assumed to be
and the A
carried through
The theoftunnel
height only if feet
the tunnel its height is strictly nel. Note: Boxbox tan
less than the tunnel's height
the other end of the tunnel. N
d thethe volumete
transported to Mes canng
of each box that can be successfully
be rotated.
5 feet tall,
so it c a n pass through the tunnel nd .
and
its
.The first box is really low, only volume is s
5 5 125 "2
"
40 80
its volume is 1
T h e second box is
sufficiently low,
it cannot pass.
Ihe same can be said abous.
41 feet tall, so
.The third box is exactly
box
Web Link: https://www.hackerrank.com/challenges/too-high-DOxes/problem?h r=internal-searek

Sample Input & Output

Output
S. no Input

Algorithm: *nclude <stdio h>


Struct boz

fnt Jength, edh, hei ght

3
type def struct bo b o

nt get-volume (loox b)

retun (bheiohtb.Jenath buoid th)


int ecoea than- max-height ( bOx b)

(6.hetkt <41)
R

ee
R
xetusn D
Page 308 of 368
COMPUTATIONAL THINKING FOR STRUCTURED DESIGN
Execution:

fnt mafnt)

nt
scant({.d", LnD;
bex bezey mall (n sizedf (bex)

o (nt tzo, fcnit+)i


scanf CA/'d/d',kbo1esCi1.Jength,Lbenea i1. ueth, Lbove, (r
heiqht),

frt (int iz 0 ien , f++)

Cis-lousu- Than_maY- heig ht (boves fi)

printf C %d\n", get-volume (bones ti]});


3
re wn O,
Test case Table:

Testcase# Testcase Type Input Expected Output after Testcase Result:


output Program Pass/Fail
25 25
2
10

80
toS 2
S
20 Pad
(For Evaluator's use onl)

Comment of the Evaluator (if Any)


Evaluator's Observation
Marks
Secured: _out of S
Full Name of the Evaluator:

,)
Sighatyreof the Evaluator Date of Evaluation:

Page 309 of 368


S IC
Date of the Session: J employee
Details like employee id, ame, salary and
stores
Problem 2:
program
that
Use Nested
shuuhres
To Execute a DOB,
store and print
s t r u c t u r e s . To
using
Output
Sample Input & Output
Input
.no

Algorithm

n c l u d e <stdio.h>

struc employee

fnt employee_fd;

char name [20]


Struct detalls

dong fn Salauy;
int dd
int mms
fnt 993B
3d
3e
int mainC)
e.employe-
S 4Sd 1d d d
Scanftd ed.o, xe.d.yIY)
e.name,ae.d.salaty ,

idin .d/-d -1.d, empoytt-1


e.
Printf(.dn/sin/-

ename, e.d.salauy,
e.d. dde.d. mm e:d999)

setuun 0

Page 312 of 368

You might also like