-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx 4A..Function.cpp
More file actions
42 lines (42 loc) · 908 Bytes
/
Copy pathEx 4A..Function.cpp
File metadata and controls
42 lines (42 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
#include<math.h>
using namespace std;
void reverse(int n)
{
int a;
cout<<"\nReverse output without return type is =";
while(n!=0)
{
a=n%10;
cout<<a;
n=n/10;
}
}
int reverse1(int n)
{
int a,c=0,x,z,b[100],i=0;
while(n!=0)
{
b[i]=n%10;
i++;
x=i;
n=n/10;
}
int y=x-1;
for(i=0; i<=x-1;i++)
{
z=b[i]*pow(10,y);
c=c+z;
y--;
}
return c;
}
int main()
{
int n;
cout<<"\nEnter the number to be reversed \n";
cin>>n;
reverse(n);
cout<<"\nReverse output with return type is ="<<reverse1(n);
return 0;
}