Need help with programming language Create programs in C++ or C#, Python and Vis
ID: 3863413 • Letter: N
Question
Need help with programming language
Create programs in C++ or C#, Python and Visual Basic which perform each of the following:
Explain the different design choices (syntax) for option in each language
Document the programs using Flowcharts
Each programs source code must be included – label each with the language used:
a) Nested two-way selection statements
b) Multiple-way selection statement
c) Iterative Statements – Counter controlled and Logic controlled
d) After the Counter Controlled Iterative successfully completes – Display "This was a success" on the screen.
Explanation / Answer
# Python Program to demonstrate the use of Nested 2 way selectors, Multiple way selectors, Iterative statements
count = int(raw_input("Enter the count of numbers to add: "))
i = 0
sum = 0
result = 0
flag = None
numbersList = []
# Counter controlled Iterative statement
while (i<count):
num = int(raw_input("Enter the number: "))
numbersList.append(num)
sum = sum + (num)
i = i+1
# Nested 2 way selectors
if sum == 0 :
if count == 0 :
result = 0
else :
result = sum
print "Sum of the numbers: " + str(result)
# Multiple way selectors:
if count < 10:
flag = "Less than 10"
elif count < 100:
flag = "Less than 100"
elif count < 1000:
flag = "Less than 1000"
print "How many numbers are there: " + flag
# Logically controlled Iterative statement
print "Entered positive numbers are: "
for i in numbersList:
if (i < 0):
break
else:
print i
OUTPUT:
>python loop.py
Enter the count of numbers to add: 5
<type 'int'>
Enter the number: 2
Enter the number: 3
Enter the number: -5
Enter the number: 4
Enter the number: -4
Sum of the numbers: 0
How many numbers are there: Less than 10
Entered positive numbers are:
2
3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.