about-text

SoftOSet is the most remarkable programming site. SoftOSet provides the fresh conceptual and professional programs, articles, books, and other interesting and technical writings. SoftOSet is the most reliable programming site to learn the programs and the basics of the popular programming languages. SoftOSet is the hub of the informative and research based articles.

C Plus Plus Program to Split 5 Digit Number


Splitting a Five digit number in c plus plus



One of my friend is continuously requesting me to write a C++ program which will take the 5 digit number from the user and then split each its digit.

So, I come up with this program this will exactly do

This C++ program will ask the user to enter a five digit number and then split this number in five digits.

C Plus Plus Program to Split 5 Digit Number

Program Code

 

#include<iostream>
using namespace std;
int main()
{
            int a,b,c,d,e,f;
            cout<<"Enter a five digit number\n";
            cin>>a;
            b=a/10000;
            c=a%10000/1000;
            d=a%1000/100;
            e=a%100/10;
            f=a%10;
            cout<<b<<"  "<<c<<"   "<<d<<"   "<<e<<"   "<<f<<"   ";
            return 0;
}
 

 C Plus Plus Program to Split 5 Digit Number

Program Output

This is the screen shot of the output of this program. You can clearly see that the 5 digit number is separated.

 

 

 

Splitting a Five digit number in c plus plus

 

 

 

That’s it.

Thanks!

 

If you have trouble in any sort of program. Please contact us, our team of experts will help you instantly.


Post a Comment

Feel Free to Comment Us

Previous Post Next Post

Recents