Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions C++/Program 22/adding_two_string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Program : To add 2 string

this Program is Contributed by Abhishek Jaiswal
*/

#include <iostream>
using namespace std;

int Len(string &str1, string &str2)
{
int len1 = str1.size();
int len2 = str2.size();
if (len1 < len2)
{
for (int i = 0 ; i < len2 - len1 ; i++)
str1 = '0' + str1;
return len2;
}
else if (len1 > len2)
{
for (int i = 0 ; i < len1 - len2 ; i++)
str2 = '0' + str2;
}
return len1;
}

string add( string a, string b )
{
string result;
int len = Len(a, b);

int carry = 0;
for (int i = len-1 ; i >= 0 ; i--)
{
int aBit = a.at(i) - '0';
int bBit = b.at(i) - '0';
int sum = (aBit ^ bBit ^ carry)+'0';

result = (char)sum + result;
carry = (aBit & bBit) | (bBit & carry) | (aBit & carry);
}

if (carry)
result = '1' + result;

return result;
}

int main()
{
string str1,str2;
cout<<"Enter the string 1 :";
cin>>str1;
cout<<"Enter the string 2 :";
cin>>str2;
cout << "Sum is " << add(str1, str2);
return 0;
}
3 changes: 3 additions & 0 deletions C++/Program 22/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program : To add Two Binary Number
Input : Two Number consitising of 0 and 1
Output : Number Constisting of 0 and 1
4 changes: 4 additions & 0 deletions C++/Program 23/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Program :To find the sum of square of binomial coefficient
Input : Integer
Output : Integer

32 changes: 32 additions & 0 deletions C++/Program 23/sum_of_square_of_binomial_coefficient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Program :To find the sum of square of
binomial coefficient.

This Program is contributed by Abhishek Jaiswal
*/
#include <bits/stdc++.h>
using namespace std;

int factorial(int begin, int end)
{
int num = 1;
for (int i = begin; i <= end; i++)
num *= i;

return num;
}

int square(int n)
{
return factorial(n + 1, 2 * n) / factorial(1, n);
}

int main()
{
int n;
cout << "Enter the number :";
cin >> n;
cout << "The Sum of Square is " << square(n) << endl;
return 0;
}