C++ Program Separate Four Digit Number By Using Function
#include<iostream>
using namespace std;
void series(int num)
{
int a,b,c,d,e,f;//declaring a local variable
a=num/1000;
b=num%1000;
c=b/100;
d=b%100;
e=d/10;
f=d%10;
cout<<a<<" "<<c<<" "<<e<<" "<<f<<"\n";
}
int main()
{
void series(int num); //function prototype
int x; //delare a variable for input 4 digit number
cout<<"please enter the number=";
cin>>x; //input integer
series(x);//calling function
0 comments:
Post a Comment