2. প্রোগ্রোম : ক োন এ টি সমসযো সমোধোননর জনয
ম্পিউিোনরর ভোষোয়(0,1) লিলিত লনর্দনের
সমটিন কেগ্রোম বনি।
প্রোগ্রোমমিং ভোষো :
কেোগ্রোম রচনোর জনয লবলভন্ন (
েব্দ,বর্ দ,অং ,সংন ত) এবং এগুনিো লবনযোনসর
লনয়ম লমলিনয় ততলর রো হয় কেোগ্রোলমং
ভোষো।নেমন: C,C++,Java,Assembly
language etc.
প্রোগ্রোম(P R O G R A M )
ও
প্রোগ্রোমমিং
ভোষো(P R O G R A M M I N G L A N G U A G E )
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
3. 1.Source code and Object code
2.What is Translator?
3.Types of Translator
4.How to Translator
work(assembler,compiler,interpreter)
TOPIC :
TRANSLATOR
(অনুবোদক
প্রোগ্রোম)
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
7. Compiler(কম্পোইলোর) and Interpreter(ইন্টোরসরটোর)
COMPILER( িোইিোর)
সিূর্ দ কেোগ্রোমন এ সোনথ অনুবোর্ নর।
কে সব কেোগ্রোলমং ভোষোন িোইি রো হয় :
--C,C++,object-
c,C#,Pascal,COBOL,ADA,Visual
Basic,Smalltalk etc.
INTERPRETER(ইন্টোরনেিোর)
সিূর্ দ কেোগ্রোমন এ িোইন এ িোইন
নর অনুবোর্ নর।
কেসব কেোগ্রোলমং ভোষোন ইন্টোরনেিোর রো
হয়
: Basic,php,python,Perl,Ruby,javascript
etc.
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
8. কোসের ধোপেমূহ
COMPILER(কম্পোইলোর) INTERPRETER(ইন্টোরসর
টোর)
Source
code Compiler
List of error
Object code
1st Step :
2nd Step :
Input
Object
code
Output
Source
code Interpreter Output
Input
Total program translate at a time then execute
Line by line translate then
execute
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
9. কম্পোইলোর এবিং ইন্টোরসরটোসরর মসধয
পোর্ থকয
কম্পোইলোর ইন্টোরসরটোর
সিূর্ দ কেোগ্রোমন এ সোনথ অনুবোর্ নর।
কেোগ্রোনমর সব ভূি এ সোনথ ের্ে দন নর ।
িোইিোর দ্রুত োজ নর।
এ বোর কেোগ্রোম িোইি রোর পর পরবতী
িোইি রনত হয় নো।
বড় ধরননর ম্পিউিোনর কবলে বযবহোর হয়।
এ িোইন এ িোইন
নর অনুবোর্ নর।
এ িোইন নর ভূি
ের্ে দন নর।
ধীনর োজ রো।
েলতটি োনজর পূনবর্
অনুবোর্ রোর েনয়োজন
হয়।
মোইনরো ম্পিউিোনর
কবলে বযবহোর রো হয়।
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
10. অযোি লরর্ম(Algorithm)
কে পদ্ধলতনত ক োন এ টি সমসযোন ধোনপ ধোনপ সমোধোন রো
হয়,তোন অযোলগমরদম(Algorithm) বনি ।
কেমন : লতনটি সংিযোর কেো ফি লনর্ দয় রোর অযোি লরর্ম(Algorithm) ।
Step-1 : Start
Step-2 : Read/Input
Step-3 : Summation of Three numbers.
Step-4 : Print/Output
Step-5 : End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
14. Special Symbols of Flowchart
Mult-Document
Preparation
Storage of finished
goods
Logical OR
Delay
Manual Operation
Data Stored
Database
Predefined process
Alternate process
Document
Manual input
Material handling
Storage of raw
materials
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
15. সমসযো : লতনটি সংিযোর কেো ফি লনর্ দয়
রোর কলোচোিদ (Flowchart) লিি।
Start
Input a,b,c
Sum = a+b+c
End
Output sum
Step-1 : Start
Step-2 : Read/Input
Step-3 : Summation of Three
numbers.
Step-4 : Print/Output
Step-5 : End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
19. লডবোল ং(Debugging) and Error
বো েনব্দর অথ দভূি।নেোগ্রোনমর ভূিগুনিোন বো বিো হয়।
আর কেোগ্রোনম ক োন ভূি পোওয়ো ক নি তো সংনেোধন রোন বিো হয় লডবোল ং।
Syntax error
(বযো রর্ ত ভূ ি)
Logical
error(েুক্রক্তসম্মত ভূ ি)
Runtime
error(তথয ত ভূ ি)
Types of Error
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
Error : Any Unexpected output is called error.
20. ক োলডং রনত েো িোন
Editor
Compiler
Debugger
সফ্টওয়োর :
IDE(Integrated Development Environment)
IDE এর নোমসমূহ :
Eclipse
Code::Block (Open source,Cross patform)
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
21. কিোন ন(Token)
A token is the smallest element of a program that is meaningful to the compiler.
Types of Token
Keywords : int,float,while
Identifiers : sum,main
Constants : 100,555
Strings : “JAJSoftTech”
Special Symbols : [] () {}, ; * = #
Operators : +,-,*,/,%
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
22. Keyword
Keyword হনিো এমন ল ছু সংরলক্ষত েব্দ,েো এ টি লনলর্দি অথ দবহর্ রনব এবং কেোগ্রোনম এ টি
লনলর্দি োে দসিোর্ন রনব।
মে প্রোগ্রোমমিং এ 32 টট Keyword আসে
auto double int struct
break else long switch
case enum register typedef
char extern return union
float short unsigned continue
signed void efault goto
sizeof volatile do if
static while const for
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
23. Keyword বযবহোনরনর লনয়ম
Keyword িননো variable বো চিন র নোম লহনসনব বযবহোর রো হয় নো।
Keyword সমূনহর েলতটি বর্ দ small letterএর হয়।
েলর্ িননো র্ুটি keyword এ সোনথ বযবহোর রনত হয়,তোহনি মোঝিোনন ফো োাঁ স্থোন থো নত হনব।
keyword সমূনহর নোম এ টি এ েব্দ,অথ দোৎ মোনঝ ক োন ফোাঁ ো স্থোন থোন নো।
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
24. Identifier
Identifiers are used as the general terminology for naming of variables, functions and arrays.
Some identifiers are used :
A-Z,a-z,0-9,$,_
Some valid and non-valid identifier example
Valid identifiers Non-valid identifiers
Number1,Int,std_name 1number ,int, std name
Keyword(Reserved word)
Space can’t be used
Digit can not be used
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
25. Constant
Constants are also like normal variables. But, only difference is, their values can not
be modified by the program once they are defined. Constants refer to fixed values.
Types of Constants :
Integer constants – Example: 0, 1, 1218, 12482
Real or Floating point constants – Example: 0.0, 1203.03, 30486.184
Octal & Hexadecimal constants – Example: octal: (013 )8 = (11)10, Hexadecimal: (013)16 = (19)10
Character constants -Example: ‘a’, ‘A’, ‘z’
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
26. String & Special Symbols
In C, a string is a sequence of characters.
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '0'};
char greeting[] = "Hello";
Special Symbols :The following special symbols are used in C having some special meaning and thus,
cannot be used for some other purpose.[] () {}, ; * = #
Brackets[]: Opening and closing brackets are used as array element reference. These
indicate single and multidimensional subscripts.
Parentheses(): These special symbols are used to indicate function calls and function
parameters.
Braces{}: These opening and ending curly braces marks the start and end of a block of code
containing more than one executable statement.
comma (, ): It is used to separate more than one statements like for separating parameters in
function calls.
semi colon : It is an operator that essentially invokes something called an initialization list.
asterisk (*): It is used to create pointer variable.
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
27. Variable / চলক
কেোগ্রোনম ক োন এ টি নোম লর্নয় েলর্ তোর মনধয data রোিো হয়,তনব ঐ নোমটিন চি বনি।
কেমন : number 1 = 10;
Name = "JAJ SoftTech"
Variable লিিোর লনয়ম :
1.Variable এর নোম বর্ দ(A-Z,a-z).অঙ্ক(0,1....9),আন্ডোরনকোর (_) এবং ডিোর লচি ($)
বযবহোর রো হয়।
Valid Invalid
first_name "JAJ SoftTech"
Id1 JAJSoftTech@
Code1022 #JAJSoftTech
$JAJSoftTech
- -- Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
28. 2.Variable এর নোম লডক্রজি বো অঙ্ক লর্নয় শুরু হনত পোনর নো।
Invalid Valid
1number _number1,
number,
a2b
3.Keyword বো function কভলরনয়বনির নোম লহনসনব বযবহোর রো েোয় নো।
Valid Invalid
Main main
Float float
for
4. Variable এর নোনমর মোনঝ ক োন ফোাঁ ো স্থোন থোন নো।
Invalid Valid
First number first_number
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
29. Operator
C- ভোষোয় োলর্লত এবং কেৌক্রক্ত োজ রোর জনয তগুনিো লবনেষ লচি (+,-*,/) বযবহোর রো
হয়,এনর্রন অপোনরির বনি।
A + B = 7
Operand
Expression
Constand
Operator
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
30. Types of Operator
Arithmetic Operator
Assignment Operator
Relational Operator
Logical Operator
Conditional Operator
Unary Operator
Bitwise operator
Special Operator
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
32. গোমণমতক ফরমুলোসক এসেসরিসন
রূপোন্তর :
গোমণমতক এেসরিন েমতুলয মে এেসরিন
X = a2-2ab + b2 X=a*a – 2*a*b + b*b;
Area = √ s(s - a)(s - b)(s - c) Area = sqrt(s*(s-a)*(s-b)*(s-c));
x = Y X ==Y;
Y=AB2+C Y = A*B*B+C;
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
33. Assignment Operator
Operator Example Full meaning
= X = x+5 X=x+5
+= X+=5 X=x+5
-+ X-=5 X=x-5
*= X*=y X=x*y
/= X/=5 X=x/5
%= X%=5 X=x%5
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
34. Relational Operator
Operator Meaning Example Result
== Equal to 5== 2 False
!= Not equal to 5!= 2 True
< Less than 5<2 False
> Greater than 5> 2 True
<= Less than or equal to 5<= 2 False
>= Greater than or equal
to
5>= 2 True
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
35. Logical Operator
Operator Name Example
&& Logical AND A&&B
|| Logical OR A||B
! Logical NOT !a
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
36. Conditional
Operator
A ternary operator pair "?:" is available in c construct
conditional expression of the forms.
Exp1 ? Exp2 : Exp3;
Example :
If(a>b)
X=a;
Else
X=b;
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
37. Unary Operator
Operator Meaning
+ Unary Plus
- Unary minus
++ Increment
-- Decrement
! Logical implement
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
& Addressof operator
38. Bitwise Operator
Operator Meaning Example
& Binary AND Operator (A & B) = 12, i.e., 0000 1100
| Binary OR Operator (A | B) = 61, i.e., 0011 1101
^ Binary Ex-OR Operator (A ^ B) = 49, i.e., 0011 0001
>> Binary Right Shift Operator A >> 2 = 15 i.e., 0000 1111
<< Binary Left Shift Operator A << 2 = 240 i.e., 1111 0000
~ Binary One's Complement
Operator
(~A ) = ~(60), i.e,. 1100 0011
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
39. সমসযো : র্ুটি সংিযোর কেো ফি লনর্ দনয়র জনয Algorithm,Flowchart
এবং C programming code লিি।
Algorithhm :
ধোপ-1:শুরু
ধোপ-2:দুটট েিংখো ইনপুট মনই।
ধোপ-3:েিংখযো দুটট প্ োগ কমর।
ধোপ-4:প্ োগফল রদি থন কমর।
ধোপ-5:প্িষ
Flowchart :
Start
Input a,b
Sum = a+b
Output sum
End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
40. সমসযো : লতনটি সংিযোর ড় এবং কেো ফি লনর্ দনয়র
জনয Algorithm,Flowchart এবং C programming code লিি।
Algorithhm :
ধোপ-1:শুরু
ধোপ-2:েিংখযো মতনটট ইনপুট মনই।
ধোপ-3:েিংখযো মতনটটর প্ োগফল মনণ থয় কমর।
ধোপ-4:প্ োগফলসক 3 দ্বোরো ভোগ কসর গড় মনণ থয় কমর।
ধোপ-5:প্ োগফল ও গড় রদি থন কমর।
ধোপ-6:প্িষ
Start
Input a,b,c
Sum = a+b+c
Print Sum,Avg
End
Avg= Sum/3
Flowchart :
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
41. সমসযো : ক্রত্রভূনজর কক্ষত্রফি লনর্ দনয়
জনয Algorithm,Flowchart এবং C programming code লিি।
Algorithhm :
ধোপ-1:শুরু
ধোপ-2:ভূমম ও উচ্চতো ইনপুট মনই।
ধোপ-3:Area = ½*ভূমম * উচ্চতো,েূত্রটট বযবহোর কসর প্ক্ষত্রফল মনণ থয় কমর।
ধোপ-4:প্ক্ষত্রফল রদি থন কমর
ধোপ-5:প্িষ
Start
Input b,h
Area = ½*b*h
Output Area
End
Flowchart :
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
42. সমসযো : ক্রত্রভূনজর লতন বোহু র তর্র্ দয কর্ওয়ো আনছ,কক্ষত্রফি
লনর্ দনয়র জনয Algorithm,Flowchart এবং C programming code লিি।(Heron's
Formula)
Algorithm : Flowchart :
ধোপ-1:শুরু
ধোপ-2:মতনটট বোহুর বদর্ঘ থয(a,b,c) ইনপুট মনই।
ধোপ-3:অধ থপমরেীমো (s=a+b+c/2) মনণ থয় কমর।
ধোপ-4: Area = √ s(s - a)(s - b)(s - c) েূত্র বযবহোর
কসর প্ক্ষত্রফল মনণ থয় কমর।
ধোপ-5 : প্ক্ষত্রফল রদি থন কমর।
ধোপ-6:প্িষ
Start
Input a,b,c
s= a+b+c/2
Print Area
End
Area = √ s(s - a)(s - b)(s - c)
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
43. সমসযো : আয়তনক্ষনত্রর কক্ষত্রফি লনর্ দয় রোর
জনয Algorithm,Flowchart এবং C programming code লিি।
Algorithm :
ধোপ-1:শুরু
ধোপ-2:বদর্ঘ থয এবিং রস্থ ইনপুট মনই।
ধোপ-3:Area = বদর্ঘ থয*রস্থ,েূত্র বযবহোর কসর প্ক্ষত্রফল মনণ থয় কমর।
ধোপ-4: প্ক্ষত্রফল রদি থন কমর।
ধোপ-5:প্িষ।
Flowchart:
Start
Input L,W
Area = L*W
Output Area
End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
44. সমসযো : বৃনের কক্ষত্রফি লনর্ দয়
রোর Algorithm,Flowchart এবং C programming code লিি।
Algorithm : Flowchart :
ধোপ-1:শুরু
ধোপ-2:বযোেোধ থ(r) ইনপুট মনই।
ধোপ-3: Area = 3.1416*r*r,েূত্র বযবহোর কসর প্ক্ষত্রফল মনণ থয় কমর।
ধোপ-4:প্ক্ষত্রফল রদি থন কমর।
ধোপ-5:প্িষ
Start
Input r
Area = 3.1416*r*r
Output Area
End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
45. সমসযো : কসলন্টনগ্রি ককনির তোপমোত্রোন ফোনরনহোইি ককনি ে োে
রোর Algorithm,Flowchart এবং C programming code লিি।
ধোপ-1: শুরু
ধোপ-2: প্েমন্টসগ্রি তোপমোত্রো (c) মনই।
ধোপ-3: F=(c*1.8)+32,েূত্র বমেসয় ফোসরনহোইট প্েসল তোপমোত্রো মনণ থয়
কমর।
ধোপ-4: ফলোফল রদি থন।
ধোপ-5: প্িষ।
Algorithm : Flowchart:
Start
Input c
F=(c*1.8)+32
Output F
End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
46. সমসযো : ফোনরনহোইি ককনির তোপমোত্রোন কসলন্টনগ্রি ককনি
ে োে রোর Algorithm,Flowchart এবং C programming code লিি।
ধোপ-1: শুরু
ধোপ-2: ফোসরনহোইট তোপমোত্রো (f) মনই।
ধোপ-3: C=(f-32)/1.8,েূত্র বমেসয় ফোসরনহোইট প্েসল তোপমোত্রো মনণ থয় কমর।
ধোপ-4: ফলোফল রদি থন।
ধোপ-5: প্িষ।
Algorithm : Flowchart :
Start
Input f
C=(f-32)/1.8
Output F
End
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
47. Decision making Statement
Decision making statement is depending on the condition block need to be executed or not
which is decided by condition.
If the condition is "true" statement block will be executed, if condition is "false" then
statement block will not be executed.
There are three types of decision making statement :
if
if-else
switch
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
48. if -Statement
Basic Syntax :
if(condition)
{
.......
.......
}
Condition
Condition Block
Flowchart :
if condition
is false
if condition is
true
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
49. else Statement
Condition
Condition Block
Flowchart :
if condition
is false
if condition is
true
else body
Basic Syntax :
if(condition)
{
.......
.......
}
else
{
…........
.........
}
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
50. if else /else if Statement
Basic Syntax :
if(condition)
{
…......
........
}
else if(condition)
{
….......
..........
}
else if(condition)
{
…........
…......
}
else
{
…...
…...
}
if condition
else if 2
Flowchart :
false
else if
condition 2
else if
condition 1
if body
else if 1
else body
false
false
true
true
true
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
51. Switch Statement
Statement n
Statement 3
Statement 2
Statement 1 Break
Break
Break
Expression
Case 1
Case 1
Case 1
default
Basic Syntax :
switch(expression/variable)
{
case 1:
//statements
break;
case 1:
//statements
break;
case 2:
//statements
break;
.
.
default:
//statements
}
Flowchart :
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
52. সমসযো : এ টি সংিযো কজোড় নো
লবনজোড় লনর্ দয় রোর Algorithm,Flowchart এবং C programming code লিি।
Algorithm :
ধোপ-1 : শুরু
ধোপ-2 : ইনপুট num.
ধোপ-3 : num%2 ==0
হযো :প্েোড় েিংখযো।
নো : মবসেোড় েিংখযো।
ধোপ-4:প্িষ।
Input num
Num%2
==0
Print Odd Print Even
Start
End
Flowchart :
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
53. েমেযো : একটট েিংখযো ধনোত্মক
নোমক ঋণোত্মক তো মনণ থয় করোর Algorithm,Flowchart এবিং C programm
ing code মলখ।
Algorithm :
ধোপ-1 : শুরু
ধোপ-2 : ইনপুট num.
ধোপ-3 : num>0
হযো : ধনোত্মক ।
নো : ঋণোত্মক ।
ধোপ-4 : প্িষ।
Input num
Num>0
Print Positive Print negative
Start
End
Flowchart :
Yes No
Click to add text
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
54. সমসযো : র্ুটি মনধয বৃহেম
সংিযো লনর্ দয় রোর Algorithm,Flowchart এবং C programming code লিি।
Algorithm :
ধোপ-1 : শুরু
ধোপ-2 : ইনপুট a,b ।
ধোপ-3 : a>b
হযো : a বড় ।
নো : b বড় ।
ধোপ-4:প্িষ।
Input a,b
a>b ??
Print a is
largest
Print b is
largest
Start
End
Flowchart :
Yes No
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
55. েমেযো : মতনটট
েিংখযোর মসধয বৃহত্তম েিংখযো মনণ থয় করোর Algorithm,Flowchart এবিং C programming code মলখ
।
Algorithm :
ধোপ-1 : শুরু
ধোপ-2 : ইনপুট a,b ,c।
ধোপ-3 : a>b এবিং a>c ?
হযো : a বড় ।
নো :পরবতী ধোসপ
োই।
ধোপ-4 : b>a এবিং b>c ?
হযো : b বড়।
নো : c বড়।
ধোপ-5 : প্িষ ।
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
Input a,b,c
a>b &&
a>c ??
Print c is
largest
Print a is
largest
Start
End
Yes
No
b>a &&
b>c
??
Print b is
largest
YesNo
Flowchart :
56. Loops
A loop statement allows us to execute a statement or group of statements multiple times.
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
for loop
while loop
do...while loop
nested loop
Sr.No Loop Type & Description
1 while loop
Repeats a statement or group of statements while a given condition is true. It tests the condition before
executing the loop body.
2 for loop
Executes a sequence of statements multiple times and abbreviates the code that manages the loop
variable.
3
do...while loop
It is more like a while statement, except that it tests the condition at the end of the loop body.
4 nested loops
You can use one or more loops inside any other while, for, or do..while loop.
C programming language provides the following types of loops to handle looping requirements.
58. initialization;
do {
statement(s);
increment/decrement;
} while( condition );
Basic Syntax :
do...while loop
Condition
Code Block
if condition
is false
if condition is
true
Flowchart :
initialization;
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
59. Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
for loop
Basic Syntax :
for(init; condition; increment)
{
statement(s);
}
Condition
code Block
Flowchart :
if condition
is false
if condition is
true
initialization
increment
60. for ( init; condition; increment ) {
for ( init; condition; increment ){
statement(s);
}
statement(s);
}
do {
statement(s);
do {
statement(s);
}while( condition );
}while( condition );
while(condition) {
while(condition) {
statement(s);
}
statement(s);
}
nested loop
while loop do...while for loop
Provided by : Jubair Ahmed Junjun
B.Sc in Computer Science & Engineering(CSE)
Basic Syntax :