Created
January 12, 2014 19:05
-
-
Save Zulqurnain/044b543ae13b7a185394 to your computer and use it in GitHub Desktop.
C++ code to Separately Print Integer Number with spaces and Count its Numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| #include <fstream> | |
| using namespace std; | |
| int main(){ // By Zulqurnain jutt | |
| int Number,count=0,*Num; | |
| cout<<"Enter Any Integer Number :=:"; cin>>Number; cout<<"\n"; | |
| int temp=1; | |
| bool Negative=0; // if negative | |
| if(Number<0){Number*=-1,Negative=1;} | |
| for(int i=Number;i!=0;count++){ | |
| if(i==1 && count==0){ | |
| count++; | |
| break; | |
| } | |
| else{ | |
| temp*=10; | |
| } | |
| i/=10; | |
| } | |
| temp/=10; | |
| Num=new int [count]; | |
| for(int j=count-1,k=Number;k!=0;j--){ | |
| if(Negative && !j){ | |
| Num[j]=(k%10) * -1; | |
| } | |
| else{ | |
| Num[j]=k%10; | |
| } | |
| k/=10; | |
| } | |
| cout<<":: Num in Array ::\n"; | |
| for(int p=0;p<count;p++){cout<<Num[p]<<" ";} | |
| cout<<"\nNumber of Digits :=:"<<count<<"\n"; | |
| delete [] Num; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment