You are on page 1of 8

PROJECT CSC 430

FAKULTI KEJURUTERAAN MEKANIKAL UiTM SHAH ALAM

Lecturer’s name : Puan Norzehan Sakamat


CONTENT

Members’ Information................................................................................. 3

Problem........................................................................................................ 4

Objective...................................................................................................... 4

Flowchart...................................................................................................... 5

Code Program............................................................................................... 6

Program Screen............................................................................................ 7

Reference..................................................................................................... 8

2
MEMBERS’ INFORMATION

Name ID No. IC No. Contact No.

Afizu Bin Aznan 2010869844 910216-06-6029 60139075635

Mohamad Zakuan Bin M. Jafri 2010822042 911015-05-5299 60136435742

Ahmad Musthofa Bin Jais 2010825538 910806-10-5569 60127775336

3
PROBLEM

Write a program to reverse the digits of a positive integer number. For example, if the 1708
is entered, the number displayed should be 8071. (Hint: use a do statement and
continuously strip off and display the unit digit of the number. If the variable num initially
contains the number entered, the unit digit is obtained as (num % 10). After a unit digit is
displayed, dividing the number by 10 sets up the number for the next iteration. Thus, (1708
% 10) is 8 and (1708 / 10) is 170. The do statement should continue as long as the remaining
number is not zero.)

OBJECTIVE

Display the entered number in reverse order.

4
FLOWCHART

Start

reverse = 0

Enter number

If no > 0
No

Yes

digit = no % 10
reverse = reverse * 10 + digit
no = no / 10

no != 0
Yes

No

Display reverse number

End

5
CODE PROGRAM

#include<iostream>

using namespace std;

int main()

int reverse=0,no,digit;

cout<<"Enter no = ";

cin>>no;

if(no>0)

do

digit=no%10;

reverse=reverse*10+digit;

no=no/10;

while(no!=0);

cout<<"Reverse no = "<<reverse<<endl;

system("pause");

6
PROGRAM SCREEN

SAMPLE INPUT

SAMPLE OUTPUT

7
REFERENCE

 C++ Programming Lab Manual (Noor Latiffah Adam,2011)


 Problem Solving with C++ (2011)

THANK YOU PUAN NORZEHAN SAKAMAT

You might also like