From 035a6f43d788d7f2488d763a1ac5b4db46d0f751 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Oct 2020 19:21:40 +0530 Subject: [PATCH 1/2] Updated README.md --- C/program-61/program.c | 77 ++++++++++++++++++++++++++---------- Python/README.md | 3 +- Python/program-17/program.py | 24 ++++++----- Python/program-17/readme.md | 7 ---- Python/program-18/program.py | 11 ++++-- Python/program-18/readme.md | 6 --- Python/program-19/program.py | 14 ------- Python/program-19/readme.md | 1 - Python/program-20/program.py | 7 ---- 9 files changed, 79 insertions(+), 71 deletions(-) delete mode 100644 Python/program-17/readme.md delete mode 100644 Python/program-18/readme.md delete mode 100644 Python/program-19/program.py delete mode 100644 Python/program-19/readme.md delete mode 100644 Python/program-20/program.py diff --git a/C/program-61/program.c b/C/program-61/program.c index 0bfbf2dc..ca8f1a80 100644 --- a/C/program-61/program.c +++ b/C/program-61/program.c @@ -1,23 +1,58 @@ -#include -void main() +/* + This Program calulates all the prime between the range of numbers + includes the numbers which is provided. + + For e.g: 2 7 + Prime Numbers are : 2 3 5 7 +*/ + +#include +#include + +char primecheck(int); + +int main() { - double r,area,circum;//Initializing varaibles - - printf("Enter Radius:"); - scanf("%lf",&r);//getting radius. - - if(r<10)//Checks if radius is less than 10 - { - circum = 2*3.14*r;//Circumference of a circle is 2*pi*r. - - printf("The Circumference of the Circle with the given radius is: %lf",circum);//printing Circumference - } - else//If r is NOT less that 10....i.e. r is greater than 10 - { - area = 3.14*r*r;//Area of a circle is pi*r*r. - - printf("The Area of the Circle with the given radius is: %lf",area);//printing The area - } - getch(); - + int i,num1,num2,cases; + char ans; + printf("Enter Number of Test Cases: "); + scanf("%d",&cases); + while (cases--) + { + printf("Enter First Number: "); + scanf("%d",&num1); + printf("Enter Second Number: "); + scanf("%d",&num2); + + printf("Answer: "); + for(i=num1;i<=num2;i++) + { + ans = primecheck(i); + if (ans == 'y') + printf("%d ",i); + } + printf("\n"); + } + return 0; } + +char primecheck(int num) +{ + int i; + if (num == 0 || num == 1) + return 'n'; + else + { + for(i=(num-1);i>1;i--) + { + if(num%i == 0) + { + return 'n'; + } + else + continue; + } + return 'y'; + } + +} \ No newline at end of file diff --git a/Python/README.md b/Python/README.md index 0bd08b85..fa05a6c4 100644 --- a/Python/README.md +++ b/Python/README.md @@ -18,7 +18,8 @@ | Program-14 | Program to find simple interest for given principal amount, time and rate of interest. | | Program-15 | Program to sort the array and give the time to sort the array. | | Program-16 | Program to print a right angled triangle. | -| Program-17 | Program to check leap year or not. | +| Program-17 | Program to convert Binary to Decimal. | +| Program-18 | Program to check leap year or not. | diff --git a/Python/program-17/program.py b/Python/program-17/program.py index 61155765..80444473 100644 --- a/Python/program-17/program.py +++ b/Python/program-17/program.py @@ -1,10 +1,14 @@ -for i in range(1,6): - for j in range(1,6-i): - print(" ",end=" ") - for k in range(1,i+1): - print(k,end=" ") - if i>1: - for l in range(1,i+1): - print(l,end=" ") - print() - +#Python Program to Convert Decimal to Binary + +def decimalToBinary(num): + """This function converts decimal number + to binary and prints it""" + if num > 1: + decimalToBinary(num // 2) + print(num % 2, end='') + + +# decimal number +number = int(input("Enter any decimal number: ")) + +decimalToBinary(number) diff --git a/Python/program-17/readme.md b/Python/program-17/readme.md deleted file mode 100644 index bbaed778..00000000 --- a/Python/program-17/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -PROGRAM-17 -To print the given pattern(pattern.py) - 1 - 1 2 1 2 - 1 2 3 1 2 3 - 1 2 3 4 1 2 3 4 -1 2 3 4 5 1 2 3 4 5 diff --git a/Python/program-18/program.py b/Python/program-18/program.py index 456583e0..c843e104 100644 --- a/Python/program-18/program.py +++ b/Python/program-18/program.py @@ -1,4 +1,7 @@ -for i in range(1,6): - for j in range(1,i+1): - print(i,end=' ') - print() + +year = int( input('Enter Year: ')) + +if (year%4) and (year%100) and (year%400) == 0: + print('Leap year') +else: + print('Not leap year') diff --git a/Python/program-18/readme.md b/Python/program-18/readme.md deleted file mode 100644 index 6da7659a..00000000 --- a/Python/program-18/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -program to print the given pattern -1 -2 2 -3 3 3 -4 4 4 4 -5 5 5 5 5 diff --git a/Python/program-19/program.py b/Python/program-19/program.py deleted file mode 100644 index 80444473..00000000 --- a/Python/program-19/program.py +++ /dev/null @@ -1,14 +0,0 @@ -#Python Program to Convert Decimal to Binary - -def decimalToBinary(num): - """This function converts decimal number - to binary and prints it""" - if num > 1: - decimalToBinary(num // 2) - print(num % 2, end='') - - -# decimal number -number = int(input("Enter any decimal number: ")) - -decimalToBinary(number) diff --git a/Python/program-19/readme.md b/Python/program-19/readme.md deleted file mode 100644 index 28cc94e5..00000000 --- a/Python/program-19/readme.md +++ /dev/null @@ -1 +0,0 @@ -Program to convert Binary to Decimal diff --git a/Python/program-20/program.py b/Python/program-20/program.py deleted file mode 100644 index c843e104..00000000 --- a/Python/program-20/program.py +++ /dev/null @@ -1,7 +0,0 @@ - -year = int( input('Enter Year: ')) - -if (year%4) and (year%100) and (year%400) == 0: - print('Leap year') -else: - print('Not leap year') From bb8a8ac70b6f4ea6b0eaee102e2c9b187a708dc3 Mon Sep 17 00:00:00 2001 From: RachithaRai Date: Wed, 7 Oct 2020 20:40:28 +0530 Subject: [PATCH 2/2] add program --- C++/Program-7/program.cpp | 29 +++++++++++++++++++++++++++++ C++/Program-7/readme.md | 1 + 2 files changed, 30 insertions(+) create mode 100644 C++/Program-7/program.cpp create mode 100644 C++/Program-7/readme.md diff --git a/C++/Program-7/program.cpp b/C++/Program-7/program.cpp new file mode 100644 index 00000000..eacc83aa --- /dev/null +++ b/C++/Program-7/program.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() +{ + int rows, n = 1; + + cout << "Enter number of rows: \n"; + cin >> rows; + + for(int i = 0; i < rows; i++) + { + for(int line = 1; line <= rows-i; line++) + cout <<" "; + + for(int j = 0; j <= i; j++) + { + if (j == 0 || i == 0) + n = 1; + else + n = n*(i-j+1)/j; + + cout << n << " "; + } + cout << endl; + } + + return 0; +} \ No newline at end of file diff --git a/C++/Program-7/readme.md b/C++/Program-7/readme.md new file mode 100644 index 00000000..83bd1a5b --- /dev/null +++ b/C++/Program-7/readme.md @@ -0,0 +1 @@ +C++ Program to print Pascal' triangle \ No newline at end of file