0% found this document useful (0 votes)
3K views7 pages

Experiment 1

This document provides an overview of Practical Work 1 for the course EC201 Fundamental Programming. The objectives are to familiarize students with basic C programming structure, use of variables and data types, and flowchart development. It covers C program structure, variables and data types, input/process/output models, and flowcharts. It includes an example of a program to calculate cylinder volume and a task to calculate current value using a circuit.

Uploaded by

adamwaiz
Copyright
© Attribution Non-Commercial (BY-NC)
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)
3K views7 pages

Experiment 1

This document provides an overview of Practical Work 1 for the course EC201 Fundamental Programming. The objectives are to familiarize students with basic C programming structure, use of variables and data types, and flowchart development. It covers C program structure, variables and data types, input/process/output models, and flowcharts. It includes an example of a program to calculate cylinder volume and a task to calculate current value using a circuit.

Uploaded by

adamwaiz
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 7

FUNDAMENTAL PROGRAMMING EC201

Experiment: Practical Work 1 Title: C Funda !ntal"# Introduction to t$! %a"ic "tructur! o& C Pro'ra ani)ulation o& *aria%l! and data t+)!" and &lo,c$art d!*!lo) !ntObjective: At t$! !nd o& t$! )ractical ,ork "!""ion( t$! "tud!nt" ,ill %! a%l!# To &a iliar ,it$ %a"ic "tructur! o& C Pro'ra in' To kno, $o, to u"!d t$! )ro)!r *aria%l! and data t+)!" ,$!n ,rit! t$! cod! To di"tin'ui"$ %!t,!!n in)ut( )roc!"" and out)ut To dra, t$! &lo,c$art &or t$! 'i*!n "ci!nti&ic or !n'in!!rin' )ro%l! "Theory: C Pro'ra .tructur!# T$! "tructur! o& a C )ro'ra i" a )rotocol /rul!"0 to t$! )ro'ra !r( ,$il! ,ritin' a C )ro'ra - T$! '!n!ral %a"ic "tructur! o& C )ro'ra i" "$o,n in t$! Fi'ur!11 %!lo,- It u"t %! "tart ,it$ t$! )r!)roc!""or ,$ic$ d!not!d %+ #include<header file>- T$! ,$ol! )ro'ra i" controll!d ,it$in main( ) alon' ,it$ l!&t %rac! d!not!d %+ ! and ri'$t %rac!" d!not!d %+ "!in'(

#i$% & ' (a)ic * +tructure

EC201: Fundamental Programming

2aria%l! and Data T+)!"# 2aria%l! i" u"!d to "tor! t$! *alu!" t! )oraril+ durin' t$! !3!cution /runti !0 o& t$! )ro'ra - 2aria%l!" ar! allocat!d M! or+ .)ac! /in RAM0 d!)!ndin' on t$! data t+)!Fir"t +ou $a*! to d!clar! t$! n!!d!d *aria%l!" in +our )ro'ra %!&or! actuall+ u"in' it- D!clarin' t$! *aria%l!" do!"n4t 'uarant!! t$at ")ac! i" allocat!d in t$! Main M! or+ /RAM0- T$! ")ac! i" allocat!d durin' t$! !3!cution /runti !0 o& t$! )ro'ra - Rul!" &or d!clarin' 2aria%l!" in C # 125789:<T$! 1"t l!tt!r "$ould %! al)$a%!t2aria%l!" can %! co %ination o& al)$a%!t" and di'it"Und!r"cor! / 6 0 i" t$! onl+ ")!cial c$aract!r allo,!d2aria%l!" can %! ,ritt!n in %ot$ U))!rca"! and Lo,!rca"! or co %ination o& %ot$2aria%l!" ar! Ca"! .!n"iti*!No .)ac!" allo,!d %!t,!!n C$aract!r"2aria%l! na ! "$ould not ak! u"! to t$! C R!"!r*!d ;!+,ord"2aria%l! na ! "$ould not "tart ,it$ a nu %!r-

E$ : a, number, )-, boo./no, etc%

Data t+)!" d!&in! t$! t+)! o& data to %! "tor!d in *aria%l!"- .o it i" i )ortant t$at +ou !ntion t$! data t+)!( ,$!n a *aria%l! i" d!clar!d- T$!r! ar! an+ di&&!r!nt data t+)!" in C0ata Type) #ormat *onver)ion (printf) #ormat *onver)ion ()canf)

c$ar Int &loat

=1 %+t!>

?c ?d ?& ?&
Table & ' (a)ic 0ata type) u)in$ in * 1ro$ram%

?c ?d ?& ?l&

=2 %+t!"> =7 %+t!"> =< %+t!">

dou%l!

In)ut1Proc!""1Out)ut# IPO Mod!l i" a &unctional od!l and conc!)tual "c$! a o& a '!n!ral "+"t! - An IPO c$art@ta%l! id!nti&i!" a )ro'ra 4" in)ut"( it" out)ut"( and t$! )roc!""in' "t!)" r!Auir!d to tran"&or t$! in)ut" into t$! out)ut"- T$! co )ut!r" u"t &ollo, t$! "ta'!" o& In)ut1Proc!""1Out)ut- T$! INPUT "ta'! in*ol*!" )uttin' in&or ation into t$! "+"t! - M!an,$il! t$! PROCE.. "ta'! in*ol*!" doin' "o !t$in' ,it$ t$! in&or ation- And t$! OUTPUT "ta'! in*ol*!" di")la+in' r!"ult"- E3a )l! %!lo, i" t$! ulti)lication )roc!"" &or t$r!! in)ut to )roduc! on! out)ut2nput
n %
Table 3 ' (a)ic 2414O chart in * 1ro$ram%

1roce))
,B C%Cn

Output
,

EC201: Fundamental Programming

Flo,c$art# Flo,c$art i" a )ictorial "u ar+ /'ra)$ical al'orit$ 0 o& t$! d!ci"ion" /"uc$ a" )roduction( "tora'!( tran")ortation0 and &lo," / o*! !nt o& in&or ation and at!rial"0 t$at ak! u) a )roc!dur! or )roc!"" &ro %!'innin' to !nd- A &lo,c$art "$o," $o, t$! !ntir! "+"t! &unction" O*al "$a)! d!&in! "tart and t$! !nd o& !ntir! !*!ntt$!

Parall!lo'ra t$! !*!nt-

indicat!" t$! in)ut1out)ut occur in

R!ctan'l! "$a)! t!ll t$! )roc!"" in*ol*! in t$! iddl! o& t$! !*!nt-

#i$% 3 ' +ample flo5chart for multiplication pro$ram%

1ro$ram to calculate volume: Cr!at! a )ro'ra to calculat! t$! *olu ! o& t$! c+lind!r- Gi*!n t$! *alu! o& t$! radiu" i" 7 !t!r and t$! $!i'$t o& c+lind!ri" 25 !t!r- Follo, t$! )roc!dur! %!lo,# 1- Li"t out t$! *aria%l! %+ u"in' I1P1O c$art2- D!t!r in! t$! a))o)riat! data t+)!" &or +our *aria%l!"5- Dra, t$! &lo,c$art7- Writ! t$! )ro'ra in'Dcon"tantB 5-1718E5

EC201: Fundamental Programming

1- I1P1O C$artIn)ut 1- radiu" 252- Data T+)!"2aria%l!/"0 1- radiu" 2F Data T+)!" int int F F Proc!"" *olu ! B 5-1718E5 C radiu" C radiu" C 6666F6666 125Out)ut F

5- *olu ! 5- Flo,c$art

EC201: Fundamental Programming

7- Writ! Pro'ra

in'#

#include <stdio.h> #include <stdlib.h> void main( ) { int radius; int height; float volume; //because the volume is in floating number. printf(Insert the value of radius scanf(#d"$ %radius); printf(Insert the value of height scanf(#d"$ %height); !n"); !n");

volume & '.()(*+',radius,radius,height; printf(-he ans.er of volume is s/stem(pause"); 0


*The Program must be compiled and run.

#f!n"$volume);

Ta"k 1# .!ri!" Circuit-

Calculat! t$! *alu! o& t$! curr!nt I( %+ u"in' C )ro'ra in'- Follo, t$! )roc!dur! t$at +ou $a*! l!arn!d %!&or!- Gou ar! co )ul"or+ to cr!at! t$! I1P1O ta%l!( li"t t$! *aria%l!" and t$! d!t!r in! t$! data t+)!"- Dra, t$! &lo,c$art and la"tl+ ,rit! t$! )ro'ra in'- /T$! "i )l!"t i" 'ood0T$!n Co )il! and RunH

EC201: Fundamental Programming

1- I1P1O C$art-

2- Data T+)!"-

5- Flo,c$art

EC201: Fundamental Programming

7- Writ! t$! Pro'ra H /I+ u"in' t$! PC0


DDGou can !dit &ro t$! )ro'ra to calculat! *olu !-

End O& Practical Work 1

EC201: Fundamental Programming

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy