Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
33 views
19 pages
Unit 3
C LANGUAGE NOTES
Uploaded by
S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Unit 3 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
33 views
19 pages
Unit 3
C LANGUAGE NOTES
Uploaded by
S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Unit 3 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 19
Search
Fullscreen
Uma 3 ConTRot FLow : A_Decision Maxine 4 Bran cHin& ae = “used Pow deciston making Purposes - —— - used +o evaluate one oF more conditions — Es make the “decrsion whether +o €xecute a Stare set of Statement oF nob - emia Type ES OF Conn AL STATEMENTS. 4. (x? Statement :- zp expression ts +rue then it executes the Statement otherwise yumps to hext thetruction - — zt checks whether given expression is boolean ov not: = SYNTAX iF (expression) “Statement 4 5 & Statement * 2s = - 6g: F a void main (9 - int a=5,b=6,¢ § = we C= atbs oprint & ("Execute me 2) > OUTPUT: - Fuecute me 1 “\\\\\ Fz include < stdio-h 7 main () : int 4715 , b= 20; (bea) printf ("6 ts greater” ) 5° a= 3 OuTpUuT b ts qreate™:UF ~y [a - else Staten 3 co : - Tt ie used 30 that we Can Check an “| condition s clepending on the outcome of any es | Condition we can follow appropriate path —T SYNTAX ts ie (expression ) Statement 1 5 Statement 25 _. g else Statement 23, Statement 4, next ~ Statement . ~|a2 expressfon js true then Statement 4 A statement 2 wre executed otherwise Statement 3 S statement 4 ave executes) void pmain CD a | 3 | Int marks = 505 if (marks = = 40) | pant é (* student is pass”) s | __ else 7 ae , pantt (“Student is fail”) 5jy 5 \ 2 : OUTPUT: - student iS pass. \\ -\\\ FaoarRam ‘10 #inD Opp Or Even Num@éR:- LE include
int main () int number 5 pzint& (“Enter an integer: "J 5 Scan k ee — & number ) 5 tf number % 2 ==20 . ? print F ("%d ts an even Integer. , : number ) else g print F Cited ts an odd integey- 7, | number_) 3 \ oe I =a) ametuin O 4 | LOuTPUT Enter an jnteger : F = F te ae odd Integer - 7 a >.Pagano \ multiple Condition - T+ fs used execute SYNTAX =: TB Ceondition 41) —_ z Statement -1 5 else. 1 (condition 2) ff Btatement-2 Z 3 Else. ff Condition 3) ~ Statement -3 5 else 12 (condition 2) Z Statement n ia s else 3 default - statement 4 Statement - 2. FE include .< stdio- rs 53! ear] = = Ea a ieee eet FF include
Votd main ©) Tne number = 0 3 clrecy ()5 primeé ("Enter a number : eee Sean f Gs pcke Pics numbex) >a tE (rumber == ]0 ) a print F (number is equal to lo”), 4 —| else 1£ (number == 50 )) - | paint F ( “number ‘3 equal to 50” ) 9 else 1% (number == loo): print k number ig equal to loo” ) | G _ a else ~ print® ( “number fs not equak to 10,50 exiee getch (do g s iz FF include
mnt main C') int £5 20," {fe (225 ges . 4 Ppa (12 is wo 7G ‘ 1} OT elseif. (#£==!15 ) j Ss prink hf C# 2 is is “Do § _ elas 72 fxs = Ze) - : Q pint & ("a ts 20") 3 % - dese ? renee Cha TS, noF present” ) > Aawy, Switch STATEMENT: ae aoe nile exe cane options we have oa ne_option Pum the is available 3 We Can Use Switch —\ gtatement. — _ ~| SYNTAX I> = = a Switch Cexpression) —— = tase value f= Statement [bteck-4 S | break 5 Case value 2 % Statement [ blocis - Cig break 5 : case value 3+ Statement [block -3 5 ; break 9 default + - “Statement | block 5° break » 4 ~_=[The Expyessten Following the Keyword ~__| Suiteh must ‘yield an integer value » It must | be integer constants I?ke 4,2,3 - ~—=| The Keyword “case” 19 followed by > integer or character Constant, each ~_| Constant in each must be different From —__ | ait the other - ie ~~ |Fivet” the integer expresston following the Keyword Switch fs evaluated The value —————————————— EePag tg ‘Seanched against the Constant that Follow +he case Statement : va lues _ [When a match fe Found the progvam executes —\#he Statement following the Case -- IF Tino match ts Pound with any of the Case — | Statements , then statement Following the default one executed - 3 FE Tnclude setdtos h> main CD t 1 | tnt 5 : [ prmt® (“ple- Sater ano ber"G $5. ")s Beant ("“%d", Fa)S Switch Ca) / y LEE LL Case 1: print F (ign Choose One nd 5 break > case 2% print # C you Chose two " DE; break 3 | ; | { Case 5S + nee (raed chése. five "D5 Cans default + printe 7 “aavalid Choices Enter a no. bet” 445 ")s break 5 ae ¢: 2s OUTPUT . [please enter a ho hei 44523 = ——| you. Choose. Three : = i ae ase! _ Pe onan | - - : “kK ALLLI |8 a 3 lines of Code only - 7 eee _ Suppose that you have -to” ‘pt = Lthen yYou-heed to write int table oF 2 jo lines oF Code using Loop Statement , You Can deo it ky 3 WHILE Loop ;- | SYNTAX +: Variable Initialization 3 while (condition ) &q:- ink R20 /_whila (x <5 10) ~ Statement 5 Variable, increement or decreement Eqis Htt ov MW~ OF KER 5 I+ ja an entry level loop Statement -e the Condition tg C@valuated Fivst F yh it ig true then body oF loop fs executed [AFtex executing the bedy oF the. loop , +he Condition is once again evaluated 4 if iF ts true , the body is executed once again: _ Continues [The process of sepeated execution of loop _ until the condition Finally “Become: False { Control is transferred out of the - _foop- # include < 8tdio-h > fe include:
void main ¢ ) int % 5| A while. rerrie Sea ey ey 4 = = output Se 123245 67 8 9 fo. fai: Proaram To Reverse Tne Numer - - : SESE FE inélude < stdio-h> int main C) | int n , Meverse=O , wemaindew 5 int CC Enter an integer + zy : Beank ("HA”, Sia) 5 —-+ = while (n |= 0) i aa ryemainder = n% 10. 5 —~_| wreverse =a everse *10 + vemainder,’ n [= Betas] print z (Reversed numbex = %d” -veverse ) 5° ___ netwen 0 $r «| Expraination : F Suppose we wane ye verse Gi 26 n a }=0 ; a nie Veverse — (n%, 12) -. - [rev * tor yem\— 4. (26 True 26 % 10 onlot 6 — R= 6 =6 — __2. Ine to = — L =| 26/10 ‘True 2 == b R= = 2 + S a | : fata aul 2 4 ss ; i > = a\ ZR iDo- Write Loop:. Ss —~ |BYNTAX a : ia —\___vaviable initialization 5 oo ad ° - 7 ~ ae] Statements 5 =a Variable incveement or decreement 5 Es while (condition) 5 - Do- while Joop San exit Controlled loop [Btatement - =| Body of loop fs executed first 4 then the Condition fs evaluated .- IF it 's +eue then the body oF loop fs executed once again - = |The process oF execution oF body of loop Continued until the Condition Frnally io becomes false & Contvel is transferred to the otatement immediately after the loop - by] progvam to print ten multiples 0F. S&S FF include “
tt include < Conio-h> votd main (> (fy mt a, fs Az5bes ~~ bets AT ae lf print FCA \E”, ati), Botts ~~ 3 [ere Son Tae re ses 1, 2, 2, Be, | getch Od a | BS, 40, +8, 50| 4 ok_Loor ~ ByN TAX | - ae : Inet fr C ‘initialization y Cond”? 3 _inermnt [decerant} \As\ 4 Statements 5 aa = z 7 : i+ tg an entry Controlled looping Statement - In this loop , move than one variable can be tnitialised . ~\teee actions can be taken at a time I'ke Vantable. inittalization , Cond” checking 4 increement] decrement - ~\ar 18 move conerse & Plextble than othex loops - . yt He include
= ie HF include << Conto-h 7 Void main (2 int 2% 3 g for (x4 5 %K<=10 5 oc ++) £ 7 + prunth ("%A\E”, ~)3 7h 4 | getoh C9 5 t——~__| : + pesca a (tess - * | OuTpUTje] proarane fer write roultiples. of Any number include
+ Gobesuuvcas , be events 8 enh te oF een — [16 cod er Sar De Sail aheg 1¢ — ie eres ey ag La| GO. To. STATE MENT [t+ Glows us +o +vansfexr . C Program +o the eee SYNTAX. a east ce gS goto Tabetaxt 0 State ment 5 ) "When hes “goto. eraeqen fs “encoupreved” the control of the progtam jumps to Sabe 4: Caries) a gtavts executing | the Code. i : 7 €4:| FF include
&) 5 Z : vetwin O 5 4 OUTPUT 4 2 3 - 3 a
You might also like
FPL Assignment 3
PDF
No ratings yet
FPL Assignment 3
15 pages
Module 2 2
PDF
No ratings yet
Module 2 2
50 pages
Programming in C' and Data Structure: Dr. Anand Kumar M.S. Engineering College Bangalore
PDF
No ratings yet
Programming in C' and Data Structure: Dr. Anand Kumar M.S. Engineering College Bangalore
41 pages
Image To PDF 20240808 20.19.48
PDF
No ratings yet
Image To PDF 20240808 20.19.48
9 pages
04 - Unit 4. Control Statements
PDF
No ratings yet
04 - Unit 4. Control Statements
46 pages
CPR Assignment Part 1
PDF
No ratings yet
CPR Assignment Part 1
25 pages
C Programming Notes Part 2
PDF
No ratings yet
C Programming Notes Part 2
24 pages
04 Loops, Arrays, and Pointers
PDF
No ratings yet
04 Loops, Arrays, and Pointers
59 pages
551GVMENT: Programmlwg
PDF
No ratings yet
551GVMENT: Programmlwg
24 pages
Programming Keys
PDF
No ratings yet
Programming Keys
20 pages
Unit Ii
PDF
No ratings yet
Unit Ii
24 pages
Programming and Data Structures: Control Flow: Looping
PDF
No ratings yet
Programming and Data Structures: Control Flow: Looping
55 pages
PIC Chapter 2-Control Structure
PDF
No ratings yet
PIC Chapter 2-Control Structure
30 pages
Unit 2
PDF
No ratings yet
Unit 2
122 pages
Unit 3
PDF
No ratings yet
Unit 3
67 pages
Looping / Iterative Statements: While Loop
PDF
No ratings yet
Looping / Iterative Statements: While Loop
7 pages
Loops PDF
PDF
No ratings yet
Loops PDF
15 pages
While Loop 2. For Loop 3. Do While Loop: Practice The Following Concepts in This Lab
PDF
No ratings yet
While Loop 2. For Loop 3. Do While Loop: Practice The Following Concepts in This Lab
8 pages
C Language Notes-2
PDF
No ratings yet
C Language Notes-2
40 pages
Control Structure-1 (202302IGS1232001)
PDF
No ratings yet
Control Structure-1 (202302IGS1232001)
38 pages
PPS Mod-2
PDF
No ratings yet
PPS Mod-2
62 pages
Nested Loop-Break and Continue
PDF
No ratings yet
Nested Loop-Break and Continue
30 pages
Lect-06 Loops
PDF
No ratings yet
Lect-06 Loops
32 pages
Basic Programming: Vietnam Academy of Science and Technology University of Science and Technology of Hanoi
PDF
No ratings yet
Basic Programming: Vietnam Academy of Science and Technology University of Science and Technology of Hanoi
49 pages
Loop 2
PDF
No ratings yet
Loop 2
13 pages
Loops PDF
PDF
No ratings yet
Loops PDF
33 pages
Lab 5 Report
PDF
No ratings yet
Lab 5 Report
26 pages
Unit 2 (A)
PDF
No ratings yet
Unit 2 (A)
48 pages
Part II
PDF
No ratings yet
Part II
24 pages
4
PDF
No ratings yet
4
72 pages
LM - Unit4 2
PDF
No ratings yet
LM - Unit4 2
8 pages
Iteration Constructs
PDF
No ratings yet
Iteration Constructs
23 pages
Java Notes
PDF
No ratings yet
Java Notes
37 pages
Chapter 5 - Control Statement
PDF
No ratings yet
Chapter 5 - Control Statement
50 pages
Lecture 7 Control
PDF
No ratings yet
Lecture 7 Control
59 pages
Branching and Looping Programs
PDF
No ratings yet
Branching and Looping Programs
12 pages
C Programming
PDF
No ratings yet
C Programming
22 pages
Chapter 06
PDF
No ratings yet
Chapter 06
48 pages
More On Decision Making and Loops in C
PDF
No ratings yet
More On Decision Making and Loops in C
24 pages
Unit 2
PDF
No ratings yet
Unit 2
69 pages
The Decision Control Structure
PDF
No ratings yet
The Decision Control Structure
42 pages
Lecture 08 Loops
PDF
No ratings yet
Lecture 08 Loops
47 pages
Chapter5 Repetition Nva
PDF
No ratings yet
Chapter5 Repetition Nva
36 pages
Module 2 - Control Structures - Python Programming
PDF
No ratings yet
Module 2 - Control Structures - Python Programming
64 pages
Control Statements PDF
PDF
No ratings yet
Control Statements PDF
31 pages
2024 25 COL100 Lab 6 Loops
PDF
No ratings yet
2024 25 COL100 Lab 6 Loops
9 pages
Control Statements
PDF
No ratings yet
Control Statements
43 pages
C Practical File
PDF
No ratings yet
C Practical File
12 pages
Machine-Level Programming
PDF
No ratings yet
Machine-Level Programming
36 pages
T3 Decision and Iteration
PDF
No ratings yet
T3 Decision and Iteration
27 pages
5.1 Event-Controlled Loops: Iterative Statements
PDF
No ratings yet
5.1 Event-Controlled Loops: Iterative Statements
24 pages
6 - Loops in C
PDF
No ratings yet
6 - Loops in C
33 pages
Section 2. Topics: Loops Boolean Expressions Selection Structures Parallel Input/output Character Variables
PDF
No ratings yet
Section 2. Topics: Loops Boolean Expressions Selection Structures Parallel Input/output Character Variables
19 pages
Control Statements
PDF
No ratings yet
Control Statements
14 pages
CSE 109 - 2 (Johra Madam)
PDF
No ratings yet
CSE 109 - 2 (Johra Madam)
63 pages
Loop Questions
PDF
No ratings yet
Loop Questions
18 pages
Unit 3 (Softcopy)
PDF
No ratings yet
Unit 3 (Softcopy)
32 pages
Control Statements
PDF
No ratings yet
Control Statements
17 pages