বিষয়বস্তুতে চলুন

প্রোগ্রামিংয়ের মৌলিক ধারণা/লুপের উদাহরণ

উইকিবই থেকে

সিউডোকোড

[সম্পাদনা]
... এই প্রোগ্রামটি ব্যবহারকারী-নির্ধারিত স্টার্ট, স্টপ এবং ইনক্রিমেন্ট মান ব্যবহার করে While, Do এবং For লুপ গণনা প্রদর্শন করে।

Function Main
    Declare Integer start
    Declare Integer stop
    Declare Integer increment
    
    Assign start = GetValue("শুরুর")
    Assign stop = GetValue("শেষের")
    Assign increment = GetValue("বৃদ্ধির")
    Call WhileLoop(start, stop, increment)
    Call DoLoop(start, stop, increment)
    Call ForLoop(start, stop, increment)
End

Function GetValue (String name)
    Declare Integer value
    
    Output "name & " মান লিখুন:""
    Input value
Return Integer value

Function WhileLoop (Integer start, Integer stop, Integer increment)
    Output "While লুপ গণনা করছে " & start & " থেকে " & stop &
        " পর্যন্ত, প্রতি ধাপে " & increment & " করে:"
    Declare Integer count
    
    Assign count = start
    While count <= stop
        Output count
        Assign count = count + increment
    End
End

Function DoLoop (Integer start, Integer stop, Integer increment)
    Output "Do লুপ গণনা করছে " & start & " থেকে " & stop & " পর্যন্ত, প্রতি ধাপে " & increment & " করে:"
    Declare Integer count
    
    Assign count = start
    Loop
        Output count
        Assign count = count + increment
    Do count <= stop
End

Function ForLoop (Integer start, Integer stop, Integer increment)
    Output "For লুপ গণনা করছে " & start & " থেকে " & stop & " পর্যন্ত, প্রতি ধাপে " & increment & " করে:"
    Declare Integer count
    
    For count = start to stop step increment
        Output count
    End
End

আউটপুট

[সম্পাদনা]
শুরুর মান লিখুন:
1
শেষের মান লিখুন:
3
বৃদ্ধির মান লিখুন:
1
While লুপ গণনা করছে 1 থেকে 3 পর্যন্ত, প্রতি ধাপে 1 করে:
1
2
3
Do লুপ গণনা করছে 1 থেকে 3 পর্যন্ত, প্রতি ধাপে 1 করে:

1
2
3
For লুপ গণনা করছে 1 থেকে 3 পর্যন্ত, প্রতি ধাপে 1 করে:
1
2
3

ফ্লোচার্ট

[সম্পাদনা]

Loops main flowchart Loops Get Value flowchart Loops While Loop flowchart Loops Do Loop flowchart Loops For Loop flowchart

তথ্যসূত্র

[সম্পাদনা]

টেমপ্লেট:Subpage navbar