0% found this document useful (0 votes)
61 views2 pages

Basic Programming Logic Exercises

The document contains instructions for solving 5 questions involving programming steps. Question 1 generates the Fibonacci sequence up to 50 terms and prints each term. Question 2 prints a color name based on the input number range. Question 3 prints even numbers up to a user-input value. Question 4 prints 3 user-input numbers in ascending order. Question 5 iteratively calculates the sum of positive user inputs and prints the final sum.

Uploaded by

priyanshu rane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

Basic Programming Logic Exercises

The document contains instructions for solving 5 questions involving programming steps. Question 1 generates the Fibonacci sequence up to 50 terms and prints each term. Question 2 prints a color name based on the input number range. Question 3 prints even numbers up to a user-input value. Question 4 prints 3 user-input numbers in ascending order. Question 5 iteratively calculates the sum of positive user inputs and prints the final sum.

Uploaded by

priyanshu rane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Question 1-

Step 1- Declare an integer array of 50 terms.

Step 2- Initialise 1st and 2nd term of the array as 0 and 1.

Array [0] = 0

Array [1] = 1

Step 3- For “the next term till the iterator reaches the number 50” { array [i+2]=array[i+1]+array[i]

Cout array [i+2]}

Question 2-

Step 1- take an input as an integer

Step2- If (input belongs to 1 to 10)

{output “blue”}

Else if (input belongs to 10 to 20)

{output “red”}

Else if (input belongs to 20 to 30)

{output “green}

Else {output “not a correct color option”}

Question 3-

Step 1- take input till where the even numbers are to be written

For (till the input value is reached increase value of intretor by 2)

{print the value of interator starting at , interator = interator+2 }

Question 4-

Step 1- Take input as three numbers from the user

If (num1<num2 & num2<num3)

{print num1, num2, num3}

Else if (num1<num3& num2>num3)

{print num1, num3, num2}

Else If (num2<num1& num3>num1)

{print num2, num1, num3}

Else If(num3>num2& num1>num3)

{print num2, num3, num1}


Else if (num 3<num2& num2<num1)

{print num3, num2, num1}

Else {print num3, num1, num2}

Question 4-

Step 1- take a input form user and declare as variable “sum” with value 0

Step2- if (input>0)

Step3- {sum = sum + input

Go to line 1}

Step4- else(stop)

Step5 – print sum

You might also like