diff --git a/C++/Program 22/adding_two_string.cpp b/C++/Program 22/adding_two_string.cpp new file mode 100644 index 00000000..68c0b973 --- /dev/null +++ b/C++/Program 22/adding_two_string.cpp @@ -0,0 +1,59 @@ +/* +Program : To add 2 string + +this Program is Contributed by Abhishek Jaiswal +*/ + +#include +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; +} diff --git a/C++/Program 22/readme.md b/C++/Program 22/readme.md new file mode 100644 index 00000000..1144c04b --- /dev/null +++ b/C++/Program 22/readme.md @@ -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 diff --git a/C++/Program 23/readme.md b/C++/Program 23/readme.md new file mode 100644 index 00000000..33afe4b7 --- /dev/null +++ b/C++/Program 23/readme.md @@ -0,0 +1,4 @@ +Program :To find the sum of square of binomial coefficient +Input : Integer +Output : Integer + diff --git a/C++/Program 23/sum_of_square_of_binomial_coefficient.cpp b/C++/Program 23/sum_of_square_of_binomial_coefficient.cpp new file mode 100644 index 00000000..032034db --- /dev/null +++ b/C++/Program 23/sum_of_square_of_binomial_coefficient.cpp @@ -0,0 +1,32 @@ +/* +Program :To find the sum of square of +binomial coefficient. + +This Program is contributed by Abhishek Jaiswal +*/ +#include +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; +} + diff --git a/C++/Program-20/README.md b/C++/Program-20/README.md new file mode 100644 index 00000000..6a94fd2d --- /dev/null +++ b/C++/Program-20/README.md @@ -0,0 +1,4 @@ +## To find the square root of a number upto "p" no of places + + +Here we take input of that number "num" and the number "p" diff --git a/C++/Program-20/program.cpp b/C++/Program-20/program.cpp new file mode 100644 index 00000000..53f78f47 --- /dev/null +++ b/C++/Program-20/program.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + + +float square_root(int num,int p) { + int s=0; + int e=num; + float ans=-1; + while(s<=e) { + int mid=s+e>>1; // (s+e)/2 + if(mid*mid==num) { + return mid; + } + else if(mid*mid>=num) { + e=mid-1; + + } + else { //as 7*7 is vey close to 50 + s=mid+1; + ans=mid; + } + } + + //for floating part + //brute force + float inc=0.1; + for(int i=1;i<=p;i++) { + while(ans*ans<=num) { + ans=ans+inc; + } + //when this blows up + ans=ans-inc;//comeback 1 step + inc/=10; + } + return ans; + +} + +int main() { + int num,p; + cin>>num;///the input number of which you want to find the square root + cin>>p;//find the square root upto "p" no of places + cout< +using namespace std; +typedef long long int ll; + +void solve() +{ + ll n = 0, m = 0; + int b[60] = {0, 1, 2, 4, 7, 2, 0, 3, 4, 8, 3, 2, 6, 9, 6, 6, 3, 0, 4, 5, 0, 6, 7, 4, 2, 7, 0, 8, 9, 8, 8, 7, 6, 4, 1, 6, 8, 5, 4, 0, 5, 6, 2, 9, 2, 2, 5, 8, 4, 3, 8, 2, 1, 4, 6, 1, 8, 0, 9, 0}; + int i = 0, j = 0, sum = 0; + + cin >> n >> m; + + i = (n-1) % 60; + j = m % 60; + + if(b[j] >= b[i]) + { + cout << b[j] - b[i] << "\n"; + } + else + { + b[j] += 10; + cout << b[j] - b[i] << "\n"; + } +} + +int main() +{ + //for fast input output + ios_base::sync_with_stdio(false);cin.tie(NULL); + + solve(); + + return 0; +} \ No newline at end of file diff --git a/C++/Program18/PrintSeries.cpp b/C++/Program18/PrintSeries.cpp new file mode 100644 index 00000000..efb8b7f7 --- /dev/null +++ b/C++/Program18/PrintSeries.cpp @@ -0,0 +1,27 @@ +#include + +using namespace std; + +void printSeries(int num1,int num2){ + int count = 1; + int i = 1; + while(count < num1+1){ + int num = (3 * i) + 2; + i++; + + if((num % num2) == 0){ + + }else{ + cout<>num1>>num2; + printSeries(num1,num2); + return 0; +} diff --git a/C++/Program18/Readme.md b/C++/Program18/Readme.md new file mode 100644 index 00000000..9118f569 --- /dev/null +++ b/C++/Program18/Readme.md @@ -0,0 +1,33 @@ +## Problem + +```bash +Write a function which prints first num1 terms of the series 3n+2 which are not multiples of num2. +``` + +## Take Input +```bash +Number 1(num1) +Number 2(num2) +0 < num1 < 100 & 0 < num2 < 100 +``` + +## Sample Input + +```bash +num1 = 10; +num2 = 4; +``` +## Sample Output + +```bash +5 +11 +14 +17 +23 +26 +29 +35 +38 +41 +``` diff --git a/C++/README.md b/C++/README.md index 6c2a8fec..4ffbcb51 100644 --- a/C++/README.md +++ b/C++/README.md @@ -15,3 +15,4 @@ | Program-10 | Program to find the missing number in a Sorted Array. | Program-15 | Program to find modular exponentiation. +| Program-19| To check whether a number is in palindrome or not \ No newline at end of file diff --git a/C++/program-19/Read me.md b/C++/program-19/Read me.md new file mode 100644 index 00000000..a952e91a --- /dev/null +++ b/C++/program-19/Read me.md @@ -0,0 +1 @@ +# To check whether a number is in palindrome or not \ No newline at end of file diff --git a/C++/program-19/palindrome.cpp b/C++/program-19/palindrome.cpp new file mode 100644 index 00000000..a18f2dd0 --- /dev/null +++ b/C++/program-19/palindrome.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int num, temp, digit, rev = 0; + + cout << "Enter a positive number: "; + cin >> num; + temp = num; + while (num != 0){ + digit = num % 10; + rev = (rev * 10) + digit; + num = num / 10; + } + cout << "The reverse of the number is: " << rev << endl; + if (temp == rev){ + cout<<"The number is a palindrome."; + } + else{ + cout << "The number is not a palindrome."; + } + return 0; +} diff --git a/C/README.md b/C/README.md index 2fb8a86b..8a0b269a 100644 --- a/C/README.md +++ b/C/README.md @@ -71,3 +71,4 @@ | Program-67 | Program to calulate all the prime between the range of numbers includes the numbers which is provided. | | Program-68 | Program to accept 0s and 1s as input and print if it consists 3 consecutive 0s | | Program-69 | Program to find strong number | +| Program-70 | Program to make a simple calculator | diff --git a/C/program-70/README.md b/C/program-70/README.md new file mode 100644 index 00000000..0b00a221 --- /dev/null +++ b/C/program-70/README.md @@ -0,0 +1,3 @@ +Program 70 + +C program to make simple calculator \ No newline at end of file diff --git a/C/program-70/program70.c b/C/program-70/program70.c new file mode 100644 index 00000000..8b90c5bf --- /dev/null +++ b/C/program-70/program70.c @@ -0,0 +1,38 @@ +#include + int main() + { + char op; + float number1,number2,result; + for(int i=0; i<5;i++) + { + printf("\nEnter\n + for Addition \n - for Subtraction \n * for Multiplication \n / for Division"); + printf("\nEnter the operation you want to perform\n"); + scanf("%s",&op); + printf("Enter two numbers\n"); + scanf("%f %f",&number1,&number2); + switch(op) + { + case'+':result=number1+number2; + printf("Sum is %f\n",result); + break; + case'-':result=number1-number2; + printf("Difference is %f\n",result); + break; + case'*':result=number1*number2; + printf("Product is %f\n",result); + break; + case'/':if(number2==0) + { + printf("Division not possible\n"); + } + else + { + result=number1/number2; + printf("Quotient is %f\n",result); + } + break; + default:printf("Enter proper input\n"); + } + } + return 0; + } \ No newline at end of file diff --git a/Dart/Program1/README.md b/Dart/Program1/README.md new file mode 100644 index 00000000..9d3d8f2b --- /dev/null +++ b/Dart/Program1/README.md @@ -0,0 +1,3 @@ +Q1. Write a program to check given number is even or odd. + +Ask the number from user in variable "number" diff --git a/Dart/Program1/checkevenodd.dart b/Dart/Program1/checkevenodd.dart new file mode 100644 index 00000000..0259ae75 --- /dev/null +++ b/Dart/Program1/checkevenodd.dart @@ -0,0 +1,14 @@ +import 'dart:io'; + +void main() { + int number; + + print("Enter a number : "); + number = int.parse(stdin.readLineSync()); + + if (number.isEven) { + print("$number is an even number"); + } else if (number.isOdd) { + print("$number is an odd number"); + } +} \ No newline at end of file diff --git a/Python/Program 30/README.md b/Python/Program 30/README.md new file mode 100644 index 00000000..d941c707 --- /dev/null +++ b/Python/Program 30/README.md @@ -0,0 +1,3 @@ +Program 30 + +Program to make a simple calculator diff --git a/Python/Program 30/program.py b/Python/Program 30/program.py new file mode 100644 index 00000000..414ef65e --- /dev/null +++ b/Python/Program 30/program.py @@ -0,0 +1,48 @@ +# Program make a simple calculator + +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # Take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # Check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + break + else: + print("Invalid Input") \ No newline at end of file diff --git a/Python/README.md b/Python/README.md index c1b29aee..313454a0 100644 --- a/Python/README.md +++ b/Python/README.md @@ -21,4 +21,16 @@ | Program-17 | Program to convert Binary to Decimal. | | Program-18 | Program to check leap year or not. | | Program-19 | Program to count number of integers between 1 to 50 divisible by a number. | -| Program-20 | Program to create an array of range specified and print. | \ No newline at end of file +| Program-20 | Program to create an array of range specified and print. | +| Program-21 | Program to print the number of *. | +| Program-22 | Program to check if a number is even or odd | +| Program-23 | Program to find the all the prime numbers between the given range. | +| Program-24 | Program to convert binary number to decimal | +| Program-25 | Program of a car game which shows if the car has started or stopped | +| Program-26 | Program of a guessing game in which u guess the secret number with a guessing limit of 3 attempts. | +| Program-27 | Program which tells you the of downpayment of the house is 10% or 20% +depending if the owner has a good credit or not.The price of the house is to be entered in the output | +| Program-28 | Program to find out the GCD of any 2 given numbers | +| Program-29 | Program which will display the fibonacci series | +| Program-30 | Program to make simple calculator | +| Program-31 | Program to print Amstrong numbers | diff --git a/readme.md b/readme.md index 0a5ec0fd..32191b66 100644 --- a/readme.md +++ b/readme.md @@ -115,5 +115,5 @@ ### Tada you just made a contribution โœจ. Pat your back ๐Ÿ‘

-### If you have never made a PR before ๐Ÿ˜•, no worries, follow these steps to get going [๐Ÿ‘‰click me](https://gitme.js.org/) +### If you have never made a PR before ๐Ÿ˜•, no worries, follow these steps to get going [๐Ÿ‘‰click me](https://gitgo.swaaz.me/)