SlideShare a Scribd company logo
1 of 14
Introduction ttoo PPrrooggrraammmmiinngg 
LLeeccttuurree 44
KKeeyy WWoorrddss ooff CC 
 mmaaiinn 
 iiff 
 eellssee 
 wwhhiillee 
 ddoo 
 ffoorr
MMeemmoorryy 
66 
xx 
== 22 ++ 44 ;; 
== 66 ;;
MMeemmoorryy 
xx == aa ++ bb ;; 
a b 
x
##iinncclluuddee <<iioossttrreeaamm..hh>> 
mmaaiinn (( )) 
{{ 
iinntt aaggee11,, aaggee22,, aaggee33,, aaggee44,, aaggee55,, aaggee66,, aaggee77,, aaggee88,, aaggee99,, aaggee1100 ;; 
iinntt TToottaallAAggee ;; 
iinntt AAvveerraaggeeAAggee ;; 
ccoouutt <<<< ““ PPlleeaassee eenntteerr tthhee aaggee ooff ssttuuddeenntt 11:: ““ ;; 
cciinn >>>> aaggee11 ;; 
ccoouutt <<<< ““ PPlleeaassee eenntteerr tthhee aaggee ooff ssttuuddeenntt 22:: ““ ;; 
cciinn >>>> aaggee22 ;; 
:: 
:: 
TToottaallAAggee == aaggee11++ aaggee22 ++ aaggee33++ aaggee44++ aaggee55++aaggee66++ aaggee77++ aaggee88++aaggee99 ++ 
aaggee1100 ;; 
AAvveerraaggeeAAggee == TToottaallAAggee // 1100 ;; 
ccoouutt<<<< ““TThhee aavveerraaggee aaggee ooff tthhee ccllaassss iiss ::”” <<<< AAvveerraaggeeAAggee ;; 
}}
QQuuaaddrraattiicc EEqquuaattiioonn 
 IInn aallggeebbrraa 
yy == aaxx22 ++ bbxx ++ cc 
 IInn CC 
yy == aa**xx**xx ++ bb**xx ++ cc
aa**bb%%cc ++dd
aa**((bb%%cc)) == aa**bb%%cc 
?
DDiissccrriimmiinnaanntt 
b2 - 2a 
4c 
= b*b - 4*a*c /2 *a Incorrect 
answer 
Solution 
= (b*b - 4*a*c) /(2 *a) Correct answer
 NNoo eexxpprreessssiioonn oonn tthhee lleefftt hhaanndd 
ssiiddee ooff tthhee aassssiiggnnmmeenntt 
 IInntteeggeerr ddiivviissiioonn ttrruunnccaatteess 
ffrraaccttiioonnaall ppaarrtt 
 LLiibbeerraall uussee ooff 
bbrraacckkeettss//ppaarreenntthheessiiss
Interesting PPrroobblleemm 
GGiivveenn aa ffoouurr--ddiiggiitt iinntteeggeerr,, 
sseeppaarraattee aanndd pprriinntt tthhee ddiiggiittss 
oonn tthhee ssccrreeeenn
AAnnaallyyssiiss 
 NNuummbbeerr == 11223344 
 TTaakkee tthhee rreemmaaiinnddeerr ooff tthhee aabboovvee nnuummbbeerr aafftteerr ddiivviiddiinngg bbyy 1100 
EEgg 11223344 // 1100 ggiivveess rreemmaaiinnddeerr 44 
11223344 %% 1100 == 44 
 RReemmoovvee llaasstt ddiiggiitt 
– 11223344//1100 == 112233..44 
– 112233 ((TTrruunnccaattiioonn dduuee ttoo IInntteeggeerr DDiivviissiioonn)) 
 112233 %%1100 ggiivveess 33 
 RReemmoovvee llaasstt ddiiggiitt 
– 112233//1100 == 1122..33 
– 1122 ((TTrruunnccaattiioonn dduuee ttoo IInntteeggeerr DDiivviissiioonn)) 
 1122 %% 1100 ggiivveess rreemmaaiinnddeerr 22 
 RReemmoovvee llaasstt ddiiggiitt 
– 1122//1100 == 11..22 
– 11 ((TTrruunnccaattiioonn dduuee ttoo IInntteeggeerr DDiivviissiioonn)) 
 FFiinnaall ddiiggiitt rreemmaaiinnss
CCooddee ##iinncclluuddee <<iioossttrreeaamm..hh>> 
mmaaiinn (( )) 
{{ 
iinntt nnuummbbeerr;; 
iinntt ddiiggiitt;; 
ccoouutt <<<< ““PPlleeaassee eenntteerr aa 44 ddiiggiitt iinntteeggeerr :: ””;; 
cciinn >>>> nnuummbbeerr;; 
ddiiggiitt == nnuummbbeerr %%1100;; 
ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt <<<< ‘‘nn’’;; //// ffiirrsstt ddiiggiitt;; aanndd tthheenn <<<< ‘‘nn’’ 
nnuummbbeerr == nnuummbbeerr // 1100;; 
ddiiggiitt == nnuummbbeerr %% 1100;; 
ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt <<<< ‘‘nn’’;; 
nnuummbbeerr == nnuummbbeerr // 1100;; 
ddiiggiitt == nnuummbbeerr %% 1100;; 
ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt <<<< ‘‘nn’’;; 
nnuummbbeerr == nnuummbbeerr // 1100;; 
ddiiggiitt == nnuummbbeerr %% 1100;; 
ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt;; 
}}
SSppeecciiaall CChhaarraacctteerr 
NNeewwlliinnee 
nn

More Related Content

What's hot

Command Channel Slides Week Between Sept. 26 to Oct. 2
Command Channel Slides Week Between Sept. 26 to Oct. 2Command Channel Slides Week Between Sept. 26 to Oct. 2
Command Channel Slides Week Between Sept. 26 to Oct. 2U.S. Army Garrison Japan
 
Vocab week ppt #8 male mono mal inter mis
Vocab week ppt #8 male mono mal inter misVocab week ppt #8 male mono mal inter mis
Vocab week ppt #8 male mono mal inter misMr Tanada
 
FISIKA TANAH
FISIKA TANAHFISIKA TANAH
FISIKA TANAHEDIS BLOG
 
Presentación curso 2014 - 15
Presentación curso 2014 - 15Presentación curso 2014 - 15
Presentación curso 2014 - 15MercheClemente
 
Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
 Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
Parecer Técnico-Científicodo perito independente Leví Inimá de MirandaMarcelo Auler
 
12. conversation starters, psu observation assignment, data
12. conversation starters, psu observation assignment, data12. conversation starters, psu observation assignment, data
12. conversation starters, psu observation assignment, dataIECP
 
Daftar kepustakaan
Daftar kepustakaanDaftar kepustakaan
Daftar kepustakaaneryeryey
 
9221492614
92214926149221492614
9221492614meyates
 
Nguyen kim doanh ta
Nguyen kim doanh taNguyen kim doanh ta
Nguyen kim doanh taDuy Quang
 
Batalion zoska
Batalion zoskaBatalion zoska
Batalion zoskaAnna Sz.
 
Command Channel Slides Week Between Oct. 24 to 30
Command Channel Slides Week Between Oct. 24 to 30Command Channel Slides Week Between Oct. 24 to 30
Command Channel Slides Week Between Oct. 24 to 30U.S. Army Garrison Japan
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40Bilal Ahmed
 
Anos 20 tenentismo e modernismo - rafael noronha
Anos 20    tenentismo e modernismo - rafael noronhaAnos 20    tenentismo e modernismo - rafael noronha
Anos 20 tenentismo e modernismo - rafael noronhaRafael Noronha
 

What's hot (20)

Mediciones radiograficas de columna
Mediciones radiograficas de columnaMediciones radiograficas de columna
Mediciones radiograficas de columna
 
Tiroiditis subaguda
Tiroiditis subagudaTiroiditis subaguda
Tiroiditis subaguda
 
El amor de Jesús
El amor de JesúsEl amor de Jesús
El amor de Jesús
 
Command Channel Slides Week Between Sept. 26 to Oct. 2
Command Channel Slides Week Between Sept. 26 to Oct. 2Command Channel Slides Week Between Sept. 26 to Oct. 2
Command Channel Slides Week Between Sept. 26 to Oct. 2
 
Vocab week ppt #8 male mono mal inter mis
Vocab week ppt #8 male mono mal inter misVocab week ppt #8 male mono mal inter mis
Vocab week ppt #8 male mono mal inter mis
 
FISIKA TANAH
FISIKA TANAHFISIKA TANAH
FISIKA TANAH
 
Presentación curso 2014 - 15
Presentación curso 2014 - 15Presentación curso 2014 - 15
Presentación curso 2014 - 15
 
Ageing male
Ageing maleAgeing male
Ageing male
 
Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
 Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
 
12. conversation starters, psu observation assignment, data
12. conversation starters, psu observation assignment, data12. conversation starters, psu observation assignment, data
12. conversation starters, psu observation assignment, data
 
Daftar kepustakaan
Daftar kepustakaanDaftar kepustakaan
Daftar kepustakaan
 
9221492614
92214926149221492614
9221492614
 
Nguyen kim doanh ta
Nguyen kim doanh taNguyen kim doanh ta
Nguyen kim doanh ta
 
A perigosa influência da tv
A perigosa influência da tvA perigosa influência da tv
A perigosa influência da tv
 
Batalion zoska
Batalion zoskaBatalion zoska
Batalion zoska
 
Command Channel Slides Week Between Oct. 24 to 30
Command Channel Slides Week Between Oct. 24 to 30Command Channel Slides Week Between Oct. 24 to 30
Command Channel Slides Week Between Oct. 24 to 30
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
 
Sintering furnace
Sintering furnaceSintering furnace
Sintering furnace
 
2 la exploración del sistema solar 2
2 la exploración del sistema solar 22 la exploración del sistema solar 2
2 la exploración del sistema solar 2
 
Anos 20 tenentismo e modernismo - rafael noronha
Anos 20    tenentismo e modernismo - rafael noronhaAnos 20    tenentismo e modernismo - rafael noronha
Anos 20 tenentismo e modernismo - rafael noronha
 

Viewers also liked

Big Data Fundamentals
Big Data FundamentalsBig Data Fundamentals
Big Data FundamentalsSmarak Das
 
Tugas Metode numerik newton Pendidikan Matematika UMT
Tugas Metode numerik newton Pendidikan Matematika UMTTugas Metode numerik newton Pendidikan Matematika UMT
Tugas Metode numerik newton Pendidikan Matematika UMTrukmono budi utomo
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 
Week1 -lecture
Week1 -lectureWeek1 -lecture
Week1 -lecturesuncil007
 
Bab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggalBab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggalAgung Sakepris
 
CS201- Introduction to Programming- Lecture 02
CS201- Introduction to Programming- Lecture 02CS201- Introduction to Programming- Lecture 02
CS201- Introduction to Programming- Lecture 02Bilal Ahmed
 
2014 Shipper Symposium - Innovation Solutions for the Mexican Market
2014 Shipper Symposium - Innovation Solutions for the Mexican Market2014 Shipper Symposium - Innovation Solutions for the Mexican Market
2014 Shipper Symposium - Innovation Solutions for the Mexican MarketTransplace
 
From Problems to Preventive Care
From Problems to Preventive CareFrom Problems to Preventive Care
From Problems to Preventive Carefaultyadult7689
 
Understanding sql Injection
Understanding sql InjectionUnderstanding sql Injection
Understanding sql InjectionPotato
 
Tindak misioner dalam pemikiran St. Conforti
Tindak misioner dalam pemikiran St. ConfortiTindak misioner dalam pemikiran St. Conforti
Tindak misioner dalam pemikiran St. ConfortiMisionaris Xaverian
 
Proyecto pedro zurita 7
Proyecto pedro zurita 7 Proyecto pedro zurita 7
Proyecto pedro zurita 7 negrita13hgft
 
Retret panggilan adalah suatu proses
Retret panggilan adalah suatu prosesRetret panggilan adalah suatu proses
Retret panggilan adalah suatu prosesMisionaris Xaverian
 
Makalah teori ukuran dan peluang
Makalah teori ukuran dan peluangMakalah teori ukuran dan peluang
Makalah teori ukuran dan peluangrukmono budi utomo
 

Viewers also liked (20)

Big Data Fundamentals
Big Data FundamentalsBig Data Fundamentals
Big Data Fundamentals
 
Tugas Metode numerik newton Pendidikan Matematika UMT
Tugas Metode numerik newton Pendidikan Matematika UMTTugas Metode numerik newton Pendidikan Matematika UMT
Tugas Metode numerik newton Pendidikan Matematika UMT
 
Fish silage project
Fish silage projectFish silage project
Fish silage project
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 
Бэби офис
Бэби офисБэби офис
Бэби офис
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 
Week1 -lecture
Week1 -lectureWeek1 -lecture
Week1 -lecture
 
3months
3months3months
3months
 
Bab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggalBab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggal
 
CS201- Introduction to Programming- Lecture 02
CS201- Introduction to Programming- Lecture 02CS201- Introduction to Programming- Lecture 02
CS201- Introduction to Programming- Lecture 02
 
QCL-14-v3_[Cause-Effect Diagram]_[SIIB]_[Sandeep Majumder]
QCL-14-v3_[Cause-Effect Diagram]_[SIIB]_[Sandeep Majumder]QCL-14-v3_[Cause-Effect Diagram]_[SIIB]_[Sandeep Majumder]
QCL-14-v3_[Cause-Effect Diagram]_[SIIB]_[Sandeep Majumder]
 
2014 Shipper Symposium - Innovation Solutions for the Mexican Market
2014 Shipper Symposium - Innovation Solutions for the Mexican Market2014 Shipper Symposium - Innovation Solutions for the Mexican Market
2014 Shipper Symposium - Innovation Solutions for the Mexican Market
 
Web 2ggg
Web 2gggWeb 2ggg
Web 2ggg
 
Cómo lograr una vida mejor
Cómo lograr una vida mejorCómo lograr una vida mejor
Cómo lograr una vida mejor
 
From Problems to Preventive Care
From Problems to Preventive CareFrom Problems to Preventive Care
From Problems to Preventive Care
 
Understanding sql Injection
Understanding sql InjectionUnderstanding sql Injection
Understanding sql Injection
 
Tindak misioner dalam pemikiran St. Conforti
Tindak misioner dalam pemikiran St. ConfortiTindak misioner dalam pemikiran St. Conforti
Tindak misioner dalam pemikiran St. Conforti
 
Proyecto pedro zurita 7
Proyecto pedro zurita 7 Proyecto pedro zurita 7
Proyecto pedro zurita 7
 
Retret panggilan adalah suatu proses
Retret panggilan adalah suatu prosesRetret panggilan adalah suatu proses
Retret panggilan adalah suatu proses
 
Makalah teori ukuran dan peluang
Makalah teori ukuran dan peluangMakalah teori ukuran dan peluang
Makalah teori ukuran dan peluang
 

Similar to CS201- Introduction to Programming- Lecture 04

The anatomy of a dollar bill
The anatomy of a dollar billThe anatomy of a dollar bill
The anatomy of a dollar billSeadin Xhaferi
 
01 termoqu%e dmica
01 termoqu%e dmica01 termoqu%e dmica
01 termoqu%e dmicaIQPonce14
 
Waterand irrigation formaster gardeners
Waterand irrigation formaster gardenersWaterand irrigation formaster gardeners
Waterand irrigation formaster gardenersMohammed Pastawy
 
Wheat pill by dr sagherr part 1
Wheat pill by dr sagherr part 1Wheat pill by dr sagherr part 1
Wheat pill by dr sagherr part 1West Medicine Ward
 
Cursos Polilab - Degradação e estabilização de polímeros aula 02
Cursos Polilab - Degradação e estabilização de polímeros aula 02Cursos Polilab - Degradação e estabilização de polímeros aula 02
Cursos Polilab - Degradação e estabilização de polímeros aula 02Fernando Jose Novaes
 
emryology resp tract
emryology resp tractemryology resp tract
emryology resp tractdskumawat
 
Dielectrics lect28
Dielectrics lect28Dielectrics lect28
Dielectrics lect28Joao Tan
 
CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10Bilal Ahmed
 
Slides esclerosemultipla-100629233859-phpapp02
Slides esclerosemultipla-100629233859-phpapp02Slides esclerosemultipla-100629233859-phpapp02
Slides esclerosemultipla-100629233859-phpapp02Sara Will
 
Turing marina.busto
Turing marina.bustoTuring marina.busto
Turing marina.bustomarinabusto
 
Business plan presentation_format
Business plan presentation_formatBusiness plan presentation_format
Business plan presentation_formatbindur87
 
Syrah clones for warm climates
Syrah clones for warm climatesSyrah clones for warm climates
Syrah clones for warm climatesMatthew Fidelibus
 
Syrah clones for warm climates
Syrah clones for warm climatesSyrah clones for warm climates
Syrah clones for warm climatesMatthew Fidelibus
 
Contrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressed
Contrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressedContrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressed
Contrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressedLeve Desejo
 
Kondisi kecamatan 2
Kondisi kecamatan 2Kondisi kecamatan 2
Kondisi kecamatan 2wangutan
 
The solar system
The solar systemThe solar system
The solar systemRoberAld
 

Similar to CS201- Introduction to Programming- Lecture 04 (20)

Chapter 6 testbench
Chapter 6 testbenchChapter 6 testbench
Chapter 6 testbench
 
Resumen termoquimica1
Resumen termoquimica1Resumen termoquimica1
Resumen termoquimica1
 
The anatomy of a dollar bill
The anatomy of a dollar billThe anatomy of a dollar bill
The anatomy of a dollar bill
 
01 termoqu%e dmica
01 termoqu%e dmica01 termoqu%e dmica
01 termoqu%e dmica
 
Waterand irrigation formaster gardeners
Waterand irrigation formaster gardenersWaterand irrigation formaster gardeners
Waterand irrigation formaster gardeners
 
10 het eerste licht
10 het eerste licht10 het eerste licht
10 het eerste licht
 
Wheat pill by dr sagherr part 1
Wheat pill by dr sagherr part 1Wheat pill by dr sagherr part 1
Wheat pill by dr sagherr part 1
 
Cursos Polilab - Degradação e estabilização de polímeros aula 02
Cursos Polilab - Degradação e estabilização de polímeros aula 02Cursos Polilab - Degradação e estabilização de polímeros aula 02
Cursos Polilab - Degradação e estabilização de polímeros aula 02
 
emryology resp tract
emryology resp tractemryology resp tract
emryology resp tract
 
Dielectrics lect28
Dielectrics lect28Dielectrics lect28
Dielectrics lect28
 
MS Unit-6
MS Unit-6MS Unit-6
MS Unit-6
 
CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10
 
Slides esclerosemultipla-100629233859-phpapp02
Slides esclerosemultipla-100629233859-phpapp02Slides esclerosemultipla-100629233859-phpapp02
Slides esclerosemultipla-100629233859-phpapp02
 
Turing marina.busto
Turing marina.bustoTuring marina.busto
Turing marina.busto
 
Business plan presentation_format
Business plan presentation_formatBusiness plan presentation_format
Business plan presentation_format
 
Syrah clones for warm climates
Syrah clones for warm climatesSyrah clones for warm climates
Syrah clones for warm climates
 
Syrah clones for warm climates
Syrah clones for warm climatesSyrah clones for warm climates
Syrah clones for warm climates
 
Contrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressed
Contrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressedContrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressed
Contrarrazoes ro vinculo empregaticio reclamada ilovepdf-compressed
 
Kondisi kecamatan 2
Kondisi kecamatan 2Kondisi kecamatan 2
Kondisi kecamatan 2
 
The solar system
The solar systemThe solar system
The solar system
 

More from Bilal Ahmed

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25Bilal Ahmed
 

More from Bilal Ahmed (20)

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
 
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
 
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
 

CS201- Introduction to Programming- Lecture 04

  • 2. KKeeyy WWoorrddss ooff CC  mmaaiinn  iiff  eellssee  wwhhiillee  ddoo  ffoorr
  • 3. MMeemmoorryy 66 xx == 22 ++ 44 ;; == 66 ;;
  • 4. MMeemmoorryy xx == aa ++ bb ;; a b x
  • 5. ##iinncclluuddee <<iioossttrreeaamm..hh>> mmaaiinn (( )) {{ iinntt aaggee11,, aaggee22,, aaggee33,, aaggee44,, aaggee55,, aaggee66,, aaggee77,, aaggee88,, aaggee99,, aaggee1100 ;; iinntt TToottaallAAggee ;; iinntt AAvveerraaggeeAAggee ;; ccoouutt <<<< ““ PPlleeaassee eenntteerr tthhee aaggee ooff ssttuuddeenntt 11:: ““ ;; cciinn >>>> aaggee11 ;; ccoouutt <<<< ““ PPlleeaassee eenntteerr tthhee aaggee ooff ssttuuddeenntt 22:: ““ ;; cciinn >>>> aaggee22 ;; :: :: TToottaallAAggee == aaggee11++ aaggee22 ++ aaggee33++ aaggee44++ aaggee55++aaggee66++ aaggee77++ aaggee88++aaggee99 ++ aaggee1100 ;; AAvveerraaggeeAAggee == TToottaallAAggee // 1100 ;; ccoouutt<<<< ““TThhee aavveerraaggee aaggee ooff tthhee ccllaassss iiss ::”” <<<< AAvveerraaggeeAAggee ;; }}
  • 6. QQuuaaddrraattiicc EEqquuaattiioonn  IInn aallggeebbrraa yy == aaxx22 ++ bbxx ++ cc  IInn CC yy == aa**xx**xx ++ bb**xx ++ cc
  • 9. DDiissccrriimmiinnaanntt b2 - 2a 4c = b*b - 4*a*c /2 *a Incorrect answer Solution = (b*b - 4*a*c) /(2 *a) Correct answer
  • 10.  NNoo eexxpprreessssiioonn oonn tthhee lleefftt hhaanndd ssiiddee ooff tthhee aassssiiggnnmmeenntt  IInntteeggeerr ddiivviissiioonn ttrruunnccaatteess ffrraaccttiioonnaall ppaarrtt  LLiibbeerraall uussee ooff bbrraacckkeettss//ppaarreenntthheessiiss
  • 11. Interesting PPrroobblleemm GGiivveenn aa ffoouurr--ddiiggiitt iinntteeggeerr,, sseeppaarraattee aanndd pprriinntt tthhee ddiiggiittss oonn tthhee ssccrreeeenn
  • 12. AAnnaallyyssiiss  NNuummbbeerr == 11223344  TTaakkee tthhee rreemmaaiinnddeerr ooff tthhee aabboovvee nnuummbbeerr aafftteerr ddiivviiddiinngg bbyy 1100 EEgg 11223344 // 1100 ggiivveess rreemmaaiinnddeerr 44 11223344 %% 1100 == 44  RReemmoovvee llaasstt ddiiggiitt – 11223344//1100 == 112233..44 – 112233 ((TTrruunnccaattiioonn dduuee ttoo IInntteeggeerr DDiivviissiioonn))  112233 %%1100 ggiivveess 33  RReemmoovvee llaasstt ddiiggiitt – 112233//1100 == 1122..33 – 1122 ((TTrruunnccaattiioonn dduuee ttoo IInntteeggeerr DDiivviissiioonn))  1122 %% 1100 ggiivveess rreemmaaiinnddeerr 22  RReemmoovvee llaasstt ddiiggiitt – 1122//1100 == 11..22 – 11 ((TTrruunnccaattiioonn dduuee ttoo IInntteeggeerr DDiivviissiioonn))  FFiinnaall ddiiggiitt rreemmaaiinnss
  • 13. CCooddee ##iinncclluuddee <<iioossttrreeaamm..hh>> mmaaiinn (( )) {{ iinntt nnuummbbeerr;; iinntt ddiiggiitt;; ccoouutt <<<< ““PPlleeaassee eenntteerr aa 44 ddiiggiitt iinntteeggeerr :: ””;; cciinn >>>> nnuummbbeerr;; ddiiggiitt == nnuummbbeerr %%1100;; ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt <<<< ‘‘nn’’;; //// ffiirrsstt ddiiggiitt;; aanndd tthheenn <<<< ‘‘nn’’ nnuummbbeerr == nnuummbbeerr // 1100;; ddiiggiitt == nnuummbbeerr %% 1100;; ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt <<<< ‘‘nn’’;; nnuummbbeerr == nnuummbbeerr // 1100;; ddiiggiitt == nnuummbbeerr %% 1100;; ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt <<<< ‘‘nn’’;; nnuummbbeerr == nnuummbbeerr // 1100;; ddiiggiitt == nnuummbbeerr %% 1100;; ccoouutt <<<<““TThhee ddiiggiitt iiss:: ““ <<<< ddiiggiitt;; }}