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

CS10-8L: Computer Programming Laboratory Exercise #5A: Conditional Statements II

This document provides instructions for an exercise involving conditional statements and includes descriptions of three programming problems: 1. A palindrome number program that checks if a number is the same when reversed. 2. A Fibonacci series program that displays the terms of the Fibonacci sequence up to a number entered by the user. 3. A number reversal program that takes a number from the user and prints the reversed number. The document estimates the time to complete the exercise and provides details on implementing each of the three programming problems. It also includes a sample score sheet for grading the exercise.

Uploaded by

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

CS10-8L: Computer Programming Laboratory Exercise #5A: Conditional Statements II

This document provides instructions for an exercise involving conditional statements and includes descriptions of three programming problems: 1. A palindrome number program that checks if a number is the same when reversed. 2. A Fibonacci series program that displays the terms of the Fibonacci sequence up to a number entered by the user. 3. A number reversal program that takes a number from the user and prints the reversed number. The document estimates the time to complete the exercise and provides details on implementing each of the three programming problems. It also includes a sample score sheet for grading the exercise.

Uploaded by

Josh Hukshiam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS10-8L: Computer Programming Laboratory 

Exercise #5A: Conditional Statements II 


 
Machine Problem: 5A     Date:   
       
Name:    Section:   
 
 
Estimated Completion Time: 120 minutes 
File Name: MP5A_Surname 
 
Problem Statement: 
 
Design a program that will allow the user to select from the following: 
[1] Palindrome number: 
[2] Fibonacci Series: 
[3] Program to reverse a number: 
 
1. Palindrome number:  
 
A  palindrome  number  is  a  number  such  that  if  we  reverse  it,  it  will  not  change.  For 
example,  some  palindrome  numbers  examples  are  121,  212,  12321,  -454.  To  check 
whether  a  number  is  a  palindrome  or  not  first  we  reverse  it  and  then  compare  the 
number  obtained  with  the  original,  if  both  are  same  then  the  number  is  palindrome 
otherwise not.  
 
2. Fibonacci series: 
Fibonacci  numbers  were  invented  by  Leonardo  of  Pisa  (Fibonacci).  He  defined 
Fibonacci  numbers  as  a  growing  population  of  immortal  rabbits.  Series  of  Fibonacci 
numbers  are:  1,1,2,3,5,8,13,21.  The Fibonacci sequence is 0,1,1,2,3,5,8, 13,… where the 
first  two  terms  are  0  and  1,  and  each  term  thereafter  is the sum of the two preceding 
terms;  that  is  Fib[n]=Fib[n-1]  +  Fib[n-2].  Display  the  Fibonacci  series:  For  example,  if 
n=6, the program should display the values ​0, 1, 1, 2, 3, 5. 
 
3. Reverse a number: 
 
This  program  reverses  the  number  entered  by  the  user  and  then  prints  the  reversed 
number  on  the  screen.  For  example,  if  the  user  enters  123  as  input  then  321 is printed 
as  output.  In  our  program,  we  use  the  modulus  (%)  operator  to  obtain  the  digits  of  a 
number.  To  invert  a  number,  look  at  it  and  write  it  from  the  opposite  direction  or  the 
output  of  code  is  a  number  obtained  by  writing  the  original  number from right to left. 
To  reverse  or  invert  large  numbers  use  long  data  type  or  long  data  type  if  your 
compiler  supports  it,  if  you  still  have  large  numbers  then  use  strings  or  other  data 
structure. 
 
 
 
 
Machine Problem Score Sheet 
 
  Criteria  Score 
 
1  Palindrome number  15   
2  Fibonacci series  15   
2  Reverse a number  20   
       
  Total       
 
Raymond B. Sedilla  ____________________ 
Instructor  Date 
 

You might also like