gdsc-ipsacademy / Competitive_Programming

Dive into algorithms, data structures, and competitive programming solutions in hacktoberfest 2023! Don't forget to give a star ;)
MIT License
10 stars 19 forks source link

added snippet to convert decimal to binary #25

Closed Thejas0604 closed 11 months ago

Thejas0604 commented 11 months ago

This snippet can convert decimal into binary. To verify functionality follow these steps.

1. Add these lines above the snippet.

#include <iostream>
using namespace std;

2. Add this function below the snippet.

int main()
{
    // Binary numbers equivalant to first 10 decimal numbers
    for (int i = 0; i <= 10; i++)
    {
        cout << i << " : " << decimalToBinary(i) << endl;
    }
    return 0;
}

Output image

Thank you.