@@ -250,6 +250,34 @@ int main()
250250 cout<<"Key : "<<max_element(Map.begin(), Map.end(), pair_Compare)->ff<<endl;
251251 cout<<"Value : "<<max_element(Map.begin(), Map.end(), pair_Compare)->ss<<endl;
252252 */
253- 253+ 254+ // Convert a Decimal into Binary in C++
255+ 256+ 257+ int n;
258+ cin>>n;
259+ string binary = bitset<8 >(n).to_string ();
260+ cout<<" Raw Binary String : " <<binary<<endl;
261+ // Finding the First Occurence of '1' to Strip-Off Leading Zeroes.
262+ const static auto loc1 = binary.find (' 1' );
263+ if (loc1 != string::npos)
264+ cout<<" Stripping : " <<binary.substr (loc1)<<endl;
265+ cout<<" Integer : " <<stoi (binary)<<endl;
266+ 267+ 268+ // Check out the Datatype of a Variable in C++
269+ 270+ /*
271+ int x = 8;
272+ cout<<"Integer : "<<typeid(x).name()<<endl;
273+ cout<<"Float : "<<typeid((float)x).name()<<endl;
274+ cout<<"Long Long : "<<typeid((ll)x).name()<<endl;
275+ cout<<"Double : "<<typeid((double)x).name()<<endl;
276+ cout<<"Short : "<<typeid((short)x).name()<<endl;
277+ cout<<"Char : "<<typeid((char)x).name()<<endl;
278+ cout<<"String : "<<typeid(to_string(x)).name()<<endl;
279+ */
280+ 281+ cerr<<" TIME : " <<(float )clock () / CLOCKS_PER_SEC<<" seconds" <<endl;
254282 return 0 ;
255283}
0 commit comments