diff --git a/.github/ISSUE_TEMPLATE/contribution.md b/.github/ISSUE_TEMPLATE/contribution.md index 377f463e..b68f4055 100644 --- a/.github/ISSUE_TEMPLATE/contribution.md +++ b/.github/ISSUE_TEMPLATE/contribution.md @@ -34,6 +34,7 @@ eg-git push origin -u swaaz - The given link should be copied and pasted in web browser or go to your repo in web browser - Create a pull request +- tag @swaaz under review section ## If you are contributing for the first time,then : [click here](https://gitme.js.org/) diff --git a/C++/Program-2/Readme.md b/C++/Program-2/Readme.md new file mode 100644 index 00000000..dba37502 --- /dev/null +++ b/C++/Program-2/Readme.md @@ -0,0 +1,7 @@ +Program 2: + +Write a Program to find the number of occurrence of X element present in sorted array. +Variable description--> +n = size of array/ number of element +x = Element to be counted in array +count = veriable to count the X-number in array diff --git a/C++/Program-2/number_of_occurrence.cpp b/C++/Program-2/number_of_occurrence.cpp new file mode 100644 index 00000000..d481a7bc --- /dev/null +++ b/C++/Program-2/number_of_occurrence.cpp @@ -0,0 +1,42 @@ +#include + +using namespace std; + +class Solution{ +public: + +/* + if x is present in arr[] then returns the count + of occurrences of x, otherwise returns 0. +*/ + +int count(int arr[], int n, int x) { + + int count = 0; + for(int i=0;i> n ; + cout<<"Enter a number to be counted: "; + cin>>x; + int arr[n]; + for (int i = 0; i < n; i++) { + cin >> arr[i]; + } + Solution ob; + auto ans = ob.count(arr, n, x); + cout<< "number "< +n = number of elements/size +k = Kth element for swaping diff --git a/C++/Program-3/swap_kth_Element.cpp b/C++/Program-3/swap_kth_Element.cpp new file mode 100644 index 00000000..d0573268 --- /dev/null +++ b/C++/Program-3/swap_kth_Element.cpp @@ -0,0 +1,45 @@ +#include + +using namespace std ; + +void takeInput(int a[], int n){ + for(int i=1;i<=n;i++){ + cin>>a[i]; + } +} + +void swap_k(int a[], int n, int k){ + + int i , count = n ; + for(i=1 ; i<=n , count >= 1 ; i++ , count--){ + + if(k == i || k == count){ + swap(a[k],a[count]); + } + + } + + for(i=1;i<=n;i++){ + cout<>n ; + + int k; + cout<<"Enter Kth element to swap:"; + cin>>k ; + + int a[1000]; + takeInput(a,n); + + swap_k(a,n,k); + cout<<"\n"; + + return 0; +} diff --git a/C++/Program-4/README.md b/C++/Program-4/README.md new file mode 100644 index 00000000..e7df3251 --- /dev/null +++ b/C++/Program-4/README.md @@ -0,0 +1,2 @@ +Program -4 +Program to find the reverse of a string diff --git a/C++/Program-4/factorial.cpp b/C++/Program-4/factorial.cpp new file mode 100644 index 00000000..27796e1e --- /dev/null +++ b/C++/Program-4/factorial.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +int main() +{ + int t; + cin>>t; + while(t--){ + int n,size=200,fact[size],j=size-1,carry=0; + cin>>n; + fact[size-1]=1; + while(n>1){ + int x; + for(int k=size-1;k>=j;k--){ + x=fact[k]*n+carry; + fact[k]=x%10; + carry=x/10;} + while(carry>0){ + fact[--j]= carry%10; + carry/=10;} + n--; + } + for(int k=j;k +using namespace std; + +int main() { + string s; + cout<<"Enter the string"<>s; + int n=s.length(); + for (int i = 0; i < n / 2; i++) + swap(s[i], s[n - i - 1]); + cout< +using namespace std; + +int main() { + cout<<"enter the number\n"; + int n; + cin>>n; + int temp, rem, sum = 0; + temp = n; + while(temp>0) + { + rem = temp%10; + temp = temp/10; + sum+=rem; + } + cout<<"\nThe sum is "< +#include +#include + +int main() +{ + /* Length of the password */ + int length; + int num; + int temp; + printf("Enter the length of the password: "); + scanf("%d", &length); + printf("\nEnter the number of passwords you want: "); + scanf("%d", &num); + /* Seed number for rand() */ + srand((unsigned int) time(0) + getpid()); + + while(num--) + { + temp = length; + printf("\n"); + while(temp--) { + putchar(rand() % 56 + 65); + srand(rand()); + } + + temp = length; + } + + printf("\n"); + + return EXIT_SUCCESS; +} diff --git a/C/program-48/README.md b/C/program-48/README.md new file mode 100644 index 00000000..c7269e20 --- /dev/null +++ b/C/program-48/README.md @@ -0,0 +1,5 @@ +Program 48 + +Added a program to check if a number is even or odd. +Variable description- +num-Input number \ No newline at end of file diff --git a/C/program-48/program.c b/C/program-48/program.c new file mode 100644 index 00000000..7223701c --- /dev/null +++ b/C/program-48/program.c @@ -0,0 +1,11 @@ +#include + +int main() { + int num; + printf("Enter a number \n"); + scanf("%d",&num); + if(num%2==0) + printf("%d is an even number",num); + else + printf("%d is an odd number",num); +} \ No newline at end of file diff --git a/C/program-51/README.md b/C/program-51/README.md new file mode 100644 index 00000000..18f1c5a3 --- /dev/null +++ b/C/program-51/README.md @@ -0,0 +1,3 @@ +Program 51 + +Write an program to print duplicates in an array. \ No newline at end of file diff --git a/C/program-51/program.c b/C/program-51/program.c new file mode 100644 index 00000000..c255d1a5 --- /dev/null +++ b/C/program-51/program.c @@ -0,0 +1,20 @@ +#include + +int main() { + int arr[100],freq[100]; + int n,i; + printf("Enter the number of elements in array \n"); + scanf("%d",&n); + printf("Enter elements in the array \n"); + for(i=0;i1) + printf("%d ",i); + } + printf("\n"); +} \ No newline at end of file diff --git a/C/program-53/Readme.md b/C/program-53/Readme.md new file mode 100644 index 00000000..8809d9d9 --- /dev/null +++ b/C/program-53/Readme.md @@ -0,0 +1 @@ +Program to find the position of an element in an array \ No newline at end of file diff --git a/C/program-53/program.c b/C/program-53/program.c new file mode 100644 index 00000000..9fb90c19 --- /dev/null +++ b/C/program-53/program.c @@ -0,0 +1,22 @@ +#include +int main() +{ + int a[100],n,el,i; + printf("Enter the size of the array"); + scanf("%d",&n); + printf("Enter the elements of the array"); + for(int i=0;i +int main() +{ + char a[100],b[100]; + int f[26]={0}; + int s[26]={0}; + int k; + int len1,len2; + printf("Enter the two strings\n"); + fgets(a,100,stdin); + fgets(b,100,stdin); + for(int i=0;a[i]!='\0';++i) + f[a[i]-'a']+=1; + for(int i=0;b[i]!='\0';++i) + s[b[i]-'a']+=1; + len1 = sizeof(a)/sizeof(a[0]); + len2 = sizeof(b)/sizeof(b[0]); + if(len1 == len2) + { + for(k=0;k<26;++k) + if(f[k]!=s[k]) + break; + if(k==26) + printf("The strings are anagrams.\n"); + else + printf("The strings aren't anagrams."); + } + else + printf("The strings aren't anagrams."); + return 0; +} diff --git a/C/program-55/program.c b/C/program-55/program.c new file mode 100644 index 00000000..ff134113 --- /dev/null +++ b/C/program-55/program.c @@ -0,0 +1,22 @@ +/* Program that prints a number in binary*/ + +// start writng code from here +#include + +int main (void) +{ + int b; + unsigned int mask = 1<<31; + + printf("Input a 32bits integer number: "); + scanf("%d", &b); + + while (mask != 0){ + printf("%d", b&mask?1:0); + mask >>= 1; + } + + printf("\n"); + + return 0; +} diff --git a/C/program-55/readme.md b/C/program-55/readme.md new file mode 100644 index 00000000..42d8c087 --- /dev/null +++ b/C/program-55/readme.md @@ -0,0 +1,4 @@ +# program-55 +## Program that prints a number in binary + +This program uses bitwise operators to print a 32bits integer in binary representation diff --git a/C/program-56/README.md b/C/program-56/README.md new file mode 100644 index 00000000..cdda9057 --- /dev/null +++ b/C/program-56/README.md @@ -0,0 +1,4 @@ +Program 56 + + +Write a program in C to calculate the number of vowels and consonants in a string. diff --git a/C/program-56/program.c b/C/program-56/program.c new file mode 100644 index 00000000..12d30de1 --- /dev/null +++ b/C/program-56/program.c @@ -0,0 +1,15 @@ +#include + +int main() { + char ch[100]; + int i,count; + printf("Enter the string \n"); + fgets(ch,100,stdin); + for(i=0;ch[i]!='\0';i++) + { + if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='A'||ch[i]=='E'||ch[i]=='I'||ch[i]=='O'||ch[i]=='U') + count++; + } + printf("Number of vowels are %d \n",count); + printf("Number of consonants are %d",(i-count)); +} diff --git a/C/program-57/program.c b/C/program-57/program.c new file mode 100644 index 00000000..cac40c26 --- /dev/null +++ b/C/program-57/program.c @@ -0,0 +1,26 @@ +#include + +int main () { + float score; + printf("Enter your total score (0-100): "); + scanf("%f",&score); + if(score < 0 || score > 100) { + printf("Enter score 0 - 100 \n"); + } else if(score >= 80) { + printf("Score = %.2f , You Grade : A\n",score); + } else if(score >= 75) { + printf("Score = %.2f , You Grade : B+\n",score); + } else if(score >= 70) { + printf("Score = %.2f , You Grade : B\n",score); + } else if(score >= 65) { + printf("Score = %.2f , You Grade : C+\n",score); + } else if(score >= 60) { + printf("Score = %.2f , You Grade : C\n",score); + } else if(score >= 55) { + printf("Score = %.2f , You Grade : D+\n",score); + } else if(score >= 50) { + printf("Score = %.2f , You Grade : D\n",score); + } else { + printf("Score = %.2f , You Grade : F\n",score); + } +} \ No newline at end of file diff --git a/C/program-57/readme.md b/C/program-57/readme.md new file mode 100644 index 00000000..6d1d4966 --- /dev/null +++ b/C/program-57/readme.md @@ -0,0 +1,4 @@ +Program 57 + + +Write a program in C to calculate the grade diff --git a/C/program-58/Program.c b/C/program-58/Program.c new file mode 100644 index 00000000..709d4d23 --- /dev/null +++ b/C/program-58/Program.c @@ -0,0 +1,24 @@ + #include +void main() + +{ + //float n[10]; + int i,sum,a,b,x; + printf("enter the size of elements\n"); + scanf("%d", &x); + float n[x]; + printf("enter the values\n"); + for (i=0;i +#include + +typedef struct student +{ + + char name[25]; + char usn[15]; + float cgpa; +} S; +S s[70]; + + +void search(char name[],int n) +{ + + int i,j; + // printf("%s\n",name); + for(i=0;i +void 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(); + +} diff --git a/C/program-63/program.c b/C/program-63/program.c new file mode 100644 index 00000000..b89e54f9 --- /dev/null +++ b/C/program-63/program.c @@ -0,0 +1,16 @@ +#include +void main() +{ + int n1,n2,n3,n4,n5; + float t; + + printf("Enter Five Numbers:"); + scanf("%d %d %d %d %d",&n1,&n2,&n3,&n4,&n5); + + t=(n1+n2+n3+n4+n5)/5; + + printf("The Average of %d,%d,%d,%d,%d is %f",n1,n2,n3,n4,n5,t); + + getch(); + +} diff --git a/Java/program-2/README.md b/Java/program-2/README.md new file mode 100644 index 00000000..7ed914ac --- /dev/null +++ b/Java/program-2/README.md @@ -0,0 +1,9 @@ +Program 2 + +Given a String,check if it is a palindrome or not. + +Variable description +s= Input String +start= Starting index of String s +end= Last index of String s +flag= Variable to mark if the String is not a Palindrome \ No newline at end of file diff --git a/Java/program-2/program.java b/Java/program-2/program.java new file mode 100644 index 00000000..a9d9adda --- /dev/null +++ b/Java/program-2/program.java @@ -0,0 +1,26 @@ +import java.io.*; +import java.util.*; +class prg{ + public static void main(String args[]) + { + Scanner sc=new Scanner(System.in); + String s=sc.next(); + int start=0; + int end=s.length()-1; + int flag=0; + while(start +ARMSTRONG NUMBER + + + + diff --git a/Javascript/program-3/read.md b/Javascript/program-3/read.md new file mode 100644 index 00000000..36e6ee89 --- /dev/null +++ b/Javascript/program-3/read.md @@ -0,0 +1,3 @@ +# Program-3 +## This is a javascript program for armstrong + diff --git a/Javascript/program-4/program-4.html b/Javascript/program-4/program-4.html new file mode 100644 index 00000000..52145b20 --- /dev/null +++ b/Javascript/program-4/program-4.html @@ -0,0 +1,55 @@ + + + + Check Palindrome with JavaScript Program + + + + +
+ + +
+ + \ No newline at end of file diff --git a/Javascript/program-4/read.md b/Javascript/program-4/read.md new file mode 100644 index 00000000..80979ba9 --- /dev/null +++ b/Javascript/program-4/read.md @@ -0,0 +1,3 @@ +# Program-4 +## This is a javascript program for palindrome + diff --git a/Javascript/program-5/program-5.html b/Javascript/program-5/program-5.html new file mode 100644 index 00000000..69b109fe --- /dev/null +++ b/Javascript/program-5/program-5.html @@ -0,0 +1,47 @@ + + +MATHEMATICAL OPERATIONS OF TWO NUMBERS + + +
+ENTER NUMBER1:
+ENTER NUMBER2:
+ + + + +Reset: +Result: +
+ + + diff --git a/Javascript/program-5/read.md b/Javascript/program-5/read.md new file mode 100644 index 00000000..24771b46 --- /dev/null +++ b/Javascript/program-5/read.md @@ -0,0 +1,4 @@ +# Program-5 +## This is a javascript program for mathematical operations + + diff --git a/Javascript/program-6/program-6.html b/Javascript/program-6/program-6.html new file mode 100644 index 00000000..55d8806f --- /dev/null +++ b/Javascript/program-6/program-6.html @@ -0,0 +1,17 @@ + + + CHARACTER PROCESSING METHODS + + + + + diff --git a/Javascript/program-6/read.md b/Javascript/program-6/read.md new file mode 100644 index 00000000..61cc055a --- /dev/null +++ b/Javascript/program-6/read.md @@ -0,0 +1,3 @@ +# Program-4 +## This is a javascript program for character processing + diff --git a/Python/Program-3/README.md b/Python/Program-3/README.md new file mode 100644 index 00000000..67521f30 --- /dev/null +++ b/Python/Program-3/README.md @@ -0,0 +1,7 @@ +Program 3 + +Write a program to check whether the string is palindrome or not + +Variable description-- +a=Holds the input string +b=Holds the reverse of the string diff --git a/Python/Program-3/program.py b/Python/Program-3/program.py new file mode 100644 index 00000000..ac4daec0 --- /dev/null +++ b/Python/Program-3/program.py @@ -0,0 +1,8 @@ + + +a=input() +b=a[::-1] #String is reversed and stored in b +if (a==b): # If a and b both are equal string is Palindrome + print("String is Palindrome") +else: + print("String is not Palindrome") diff --git a/Python/program-10/armstrong.py b/Python/program-10/armstrong.py new file mode 100644 index 00000000..7e0967c6 --- /dev/null +++ b/Python/program-10/armstrong.py @@ -0,0 +1,22 @@ +#Python Program to Find Armstrong Number in an Interval + + +lower = 100 +upper = 2000 + +for num in range(lower, upper + 1): + + # order of number + order = len(str(num)) + + # initialize sum + sum = 0 + + temp = num + while temp > 0: + digit = temp % 10 + sum += digit ** order + temp //= 10 + + if num == sum: + print(num) diff --git a/Python/program-11/shufflecards.py b/Python/program-11/shufflecards.py new file mode 100644 index 00000000..df6429bd --- /dev/null +++ b/Python/program-11/shufflecards.py @@ -0,0 +1,11 @@ +# Python program to shuffle a deck of card + +import itertools, random + +deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club'])) + +random.shuffle(deck) + +print("woohh here you got:") +for i in range(5): + print(deck[i][0], "of", deck[i][1]) diff --git a/Python/program-14/git.py b/Python/program-14/git.py new file mode 100644 index 00000000..84546b60 --- /dev/null +++ b/Python/program-14/git.py @@ -0,0 +1,21 @@ +#fibonacci series +nterms = int(input("How many terms? ")) + +# first two terms +n1, n2 = 0, 1 +count = 0 + +if nterms <= 0: + print("Please enter a positive integer") +elif nterms == 1: + print("Fibonacci sequence upto",nterms,":") + print(n1) +else: + print("Fibonacci sequence:") + while count < nterms: + print(n1) + nth = n1 + n2 + # update values + n1 = n2 + n2 = nth + count += 1 \ No newline at end of file diff --git a/Python/program-14/readme.md b/Python/program-14/readme.md new file mode 100644 index 00000000..53622207 --- /dev/null +++ b/Python/program-14/readme.md @@ -0,0 +1 @@ +program to print fibonacci series diff --git a/Python/program-15/git1.py b/Python/program-15/git1.py new file mode 100644 index 00000000..9ce5c2ef --- /dev/null +++ b/Python/program-15/git1.py @@ -0,0 +1,22 @@ +# Program to check if a number is prime or not + +num = 407 + +# To take input from the user +#num = int(input("Enter a number: ")) + +# prime numbers are greater than 1 +if num > 1: + # check for factors + for i in range(2,num): + if (num % i) == 0: + print(num,"is not a prime number") + print(i,"times",num//i,"is",num) + break + else: + print(num,"is a prime number") + +# if input number is less than +# or equal to 1, it is not prime +else: + print(num,"is not a prime number") \ No newline at end of file diff --git a/Python/program-15/readme.md b/Python/program-15/readme.md new file mode 100644 index 00000000..a089d895 --- /dev/null +++ b/Python/program-15/readme.md @@ -0,0 +1 @@ +program to check whether a number is prime or not diff --git a/Python/program-16/git2.py b/Python/program-16/git2.py new file mode 100644 index 00000000..a6a74aa2 --- /dev/null +++ b/Python/program-16/git2.py @@ -0,0 +1,36 @@ +# Returns index of x in arr if present, else -1 +def binary_search(arr, low, high, x): + + # Check base case + if high >= low: + + mid = (high + low) // 2 + + # If element is present at the middle itself + if arr[mid] == x: + return mid + + # If element is smaller than mid, then it can only + # be present in left subarray + elif arr[mid] > x: + return binary_search(arr, low, mid - 1, x) + + # Else the element can only be present in right subarray + else: + return binary_search(arr, mid + 1, high, x) + + else: + # Element is not present in the array + return -1 + +# Test array +arr = [ 2, 3, 4, 10, 40 ] +x = 10 + +# Function call +result = binary_search(arr, 0, len(arr)-1, x) + +if result != -1: + print("Element is present at index", str(result)) +else: + print("Element is not present in array") \ No newline at end of file diff --git a/Python/program-16/readme.md b/Python/program-16/readme.md new file mode 100644 index 00000000..305d7c49 --- /dev/null +++ b/Python/program-16/readme.md @@ -0,0 +1 @@ +python program for binary search \ No newline at end of file diff --git a/Python/program-18/git3.py b/Python/program-18/git3.py new file mode 100644 index 00000000..cfbccef5 --- /dev/null +++ b/Python/program-18/git3.py @@ -0,0 +1,17 @@ +# Python3 program to find simple interest +# for given principal amount, time and +# rate of interest. + + +def simple_interest(p,t,r): + print('The principal is', p) + print('The time period is', t) + print('The rate of interest is',r) + + si = (p * t * r)/100 + + print('The Simple Interest is', si) + return si + +# Driver code +simple_interest(8, 6, 8) \ No newline at end of file diff --git a/Python/program-18/readme.md b/Python/program-18/readme.md new file mode 100644 index 00000000..0c0fcc1d --- /dev/null +++ b/Python/program-18/readme.md @@ -0,0 +1 @@ +python program for simple interest \ No newline at end of file diff --git a/Python/program-4/Program 4.py b/Python/program-4/Program 4.py new file mode 100644 index 00000000..77c405f9 --- /dev/null +++ b/Python/program-4/Program 4.py @@ -0,0 +1,9 @@ +# Store input numbers +num1 = input('Enter first number: ') +num2 = input('Enter second number: ') + +# Add two numbers +sum = float(num1) + float(num2) + +# Display the sum +print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) diff --git a/Python/program-4/README.md b/Python/program-4/README.md new file mode 100644 index 00000000..7137f722 --- /dev/null +++ b/Python/program-4/README.md @@ -0,0 +1,2 @@ +# triangle.py +# Draws a triangle \ No newline at end of file diff --git a/Python/program-4/sorting.py b/Python/program-4/sorting.py new file mode 100644 index 00000000..e91b5a5c --- /dev/null +++ b/Python/program-4/sorting.py @@ -0,0 +1,23 @@ +import datetime +start = datetime.datetime.now() +arr = [5, 8, 1, 3, 3, 0, 7, 4,5,8, 9, 10, 84, 34, 22] +arr_size = len(arr) +new_arr = [None]*(arr_size) +n = 0 + +for i in range(arr_size): + n=0 + for j in range(arr_size): + if arr[i] > arr[j]: + n+=1 + while new_arr[n] == arr[i]: + n+=1 + new_arr[n] = arr[i] + +arr = new_arr + +for i in range(arr_size): + print ("%d" %arr[i]), + +finish = datetime.datetime.now() +print (finish-start) diff --git a/Python/program-4/triangle.py b/Python/program-4/triangle.py new file mode 100644 index 00000000..da4902eb --- /dev/null +++ b/Python/program-4/triangle.py @@ -0,0 +1,4 @@ +for i in range(5): + for j in range(i): + print('*', end=' ') + print() \ No newline at end of file diff --git a/Python/program-5/README.md b/Python/program-5/README.md new file mode 100644 index 00000000..669d2d67 --- /dev/null +++ b/Python/program-5/README.md @@ -0,0 +1,7 @@ +Program 5 + +Write a program to find a factorial of a number. + +Variable description-- +fact= Holds the input number + diff --git a/Python/program-5/factorial.py b/Python/program-5/factorial.py new file mode 100644 index 00000000..9db2639b --- /dev/null +++ b/Python/program-5/factorial.py @@ -0,0 +1,14 @@ +fact=int(input("input any number")) +# input any number +factorial =1 +#predefined factorial of 0 +if fact<0: + print("factorial is not possible") +elif fact==0: + print("factorial of "+str(fact) +" is "+str(factorial)) +else: + fact1=fact + while(fact>2): + fact-=1 + fact1=fact1*(fact) + print("factorial is "+ str(fact1)) \ No newline at end of file diff --git a/Python/program-5/pattern.py b/Python/program-5/pattern.py new file mode 100644 index 00000000..e067d825 --- /dev/null +++ b/Python/program-5/pattern.py @@ -0,0 +1,10 @@ +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() + \ No newline at end of file diff --git a/Python/program-6/README.md b/Python/program-6/README.md new file mode 100644 index 00000000..8d8c46c6 --- /dev/null +++ b/Python/program-6/README.md @@ -0,0 +1,7 @@ +Program 6 + +Write a program to check whether a number is prime or not + +Variable description-- +n= holds input value + diff --git a/Python/program-6/pattern.py b/Python/program-6/pattern.py new file mode 100644 index 00000000..456583e0 --- /dev/null +++ b/Python/program-6/pattern.py @@ -0,0 +1,4 @@ +for i in range(1,6): + for j in range(1,i+1): + print(i,end=' ') + print() diff --git a/Python/program-6/program.py b/Python/program-6/program.py new file mode 100644 index 00000000..8b70a1d6 --- /dev/null +++ b/Python/program-6/program.py @@ -0,0 +1,14 @@ +n=int(input("enter any number")) +# n is the number to check whether it is prime or not +if n>1: + # loop from 2 to n/2 + for i in range(2,int(n/2)): + + if(n%i)==0: + #if n is completly divisible by i then it is not a prime number + print("n is not prime") + break + else: + print("n is prime") +else: + print("not prime") diff --git a/Python/program-7/pattern3.py b/Python/program-7/pattern3.py new file mode 100644 index 00000000..601bfdbb --- /dev/null +++ b/Python/program-7/pattern3.py @@ -0,0 +1,8 @@ +#pattern +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=" ") + print() + \ No newline at end of file diff --git a/Python/program-7/readme.md b/Python/program-7/readme.md new file mode 100644 index 00000000..4f87ac17 --- /dev/null +++ b/Python/program-7/readme.md @@ -0,0 +1,6 @@ +Program to print the following pattern + 1 + 1 2 + 1 2 3 + 1 2 3 4 +1 2 3 4 5 \ No newline at end of file diff --git a/Python/program-8/pattern4.py b/Python/program-8/pattern4.py new file mode 100644 index 00000000..683d48d8 --- /dev/null +++ b/Python/program-8/pattern4.py @@ -0,0 +1,6 @@ +c=0 +for i in range(0,4): + for j in range(i+1): + print(c,end=" ") + c=c+1 + print() \ No newline at end of file diff --git a/Python/program-8/readme.md b/Python/program-8/readme.md new file mode 100644 index 00000000..a3b103b0 --- /dev/null +++ b/Python/program-8/readme.md @@ -0,0 +1,5 @@ +program to print the given pattern +0 +1 2 +3 4 5 +6 7 8 9 \ No newline at end of file diff --git a/gif/giphy.gif b/gif/giphy.gif new file mode 100644 index 00000000..c5360b3a Binary files /dev/null and b/gif/giphy.gif differ diff --git a/index.html b/index.html index f6c920ff..142e7e1b 100644 --- a/index.html +++ b/index.html @@ -1,20 +1,16 @@ - - Basic Programs - - - - - - - - -
-

Basic Programs

-

Basic programs in C and Python

- -
- - - \ No newline at end of file + + Basic Programs + + + + + + +
+

Basic Programs

+

Basic programs in C and Python

+
+ + diff --git a/readme.md b/readme.md index b41b556d..17b64228 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,12 @@ -# Basic programs -## This repo contains basics programs in c programming language and python. +

Basic Program

+ +
+ +
+ +## This repo contains basics programs in all languages. ## Contribution If you want to contribute to this repo then [click here](https://github.com/swaaz/basicprograms/blob/swaaz/.github/ISSUE_TEMPLATE/contribution.md) diff --git a/src/1.jpg b/src/1.jpg deleted file mode 100644 index a7aa7071..00000000 Binary files a/src/1.jpg and /dev/null differ diff --git a/src/css/index.css b/src/css/index.css new file mode 100644 index 00000000..e69de29b diff --git a/1.jpg b/src/images/1.jpg similarity index 100% rename from 1.jpg rename to src/images/1.jpg diff --git a/src/js/index.js b/src/js/index.js new file mode 100644 index 00000000..e69de29b