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 -1/Program.cpp b/C++/Program -1/Program.cpp new file mode 100644 index 00000000..9144cf64 --- /dev/null +++ b/C++/Program -1/Program.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +#include +int main() { + cout<<"Enter the number of elements "<>n;//Input the size of array + int arr[n]; + int min=INT_MAX; + int max=INT_MIN; + cout<<"Enter the elements"<>arr[i]; + if(arr[i]max)//if current element is greater than max + max=arr[i];//max is updated + } + cout<<"Minimum element is:"< +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-49/README.md b/C/Program-49/README.md new file mode 100644 index 00000000..7766aa7c --- /dev/null +++ b/C/Program-49/README.md @@ -0,0 +1,8 @@ +Program 49 + +Write a program to find the sum of the digits of the given number. + +Variable description-- +num=Number +sum= Holds the sum +dig=Holds the single digit of the number diff --git a/C/Program-49/program.c b/C/Program-49/program.c new file mode 100644 index 00000000..cc5d2743 --- /dev/null +++ b/C/Program-49/program.c @@ -0,0 +1,18 @@ +#include + +int main() { + + int n; + printf("Enter the number"); + int num; + scanf("%d",&num);//Enter the number + int sum=0,dig=0; + while(num>0) + { + dig=num%10; + sum+=dig; + num/=10; + } + printf("The sum of digits of a number is: %d",sum); + return 0; +} diff --git a/C/Program-52/README.md b/C/Program-52/README.md new file mode 100644 index 00000000..e521142d --- /dev/null +++ b/C/Program-52/README.md @@ -0,0 +1,4 @@ +Program 52 + +Write a program to find whether the given element is present in the array or not. + diff --git a/C/Program-52/program.c b/C/Program-52/program.c new file mode 100644 index 00000000..0d916d88 --- /dev/null +++ b/C/Program-52/program.c @@ -0,0 +1,39 @@ +#include + +int main() { + int n;//number of elements of array; + printf("Enter the number of elements"); + scanf("%d",&n); + int arr[n]; + printf("\nEnter the elements"); + for(int i=0;i -int power(int x,int y) -{ int i,t=x; - for(i=1;i0) + { + a=n%10; + n=n/10; + c=c+(a*a*a); + } + if(temp==c) + printf("armstrong number\n"); + else + printf("Not armstrong number\n"); return 0; -} \ No newline at end of file +} diff --git a/C/program-19/a.out b/C/program-19/a.out deleted file mode 100755 index 2844dfd8..00000000 Binary files a/C/program-19/a.out and /dev/null differ diff --git a/C/program-2/program.c b/C/program-2/program.c index eaae4e69..414b2e8e 100644 --- a/C/program-2/program.c +++ b/C/program-2/program.c @@ -15,15 +15,15 @@ return 1; int main() /*main function */ { int n; - printf("enter the number"); + printf("Enter the number:"); scanf("%d",&n); if(isprime(n)==0) { - printf(" not prime"); + printf("%d is not prime number.",n); } else if(isprime(n)==1) { - printf("prime"); + printf("%d is a prime number.",n); } return 0; - } +} diff --git a/C/program-20/a.out b/C/program-20/a.out deleted file mode 100755 index 5d53f3ee..00000000 Binary files a/C/program-20/a.out and /dev/null differ diff --git a/C/program-21/a.out b/C/program-21/a.out deleted file mode 100755 index 241d921c..00000000 Binary files a/C/program-21/a.out and /dev/null differ diff --git a/C/program-22/a.out b/C/program-22/a.out deleted file mode 100755 index c9555c14..00000000 Binary files a/C/program-22/a.out and /dev/null differ diff --git a/C/program-23/a.out b/C/program-23/a.out deleted file mode 100755 index 99981a39..00000000 Binary files a/C/program-23/a.out and /dev/null differ diff --git a/C/program-24/a.out b/C/program-24/a.out deleted file mode 100755 index d8f80262..00000000 Binary files a/C/program-24/a.out and /dev/null differ diff --git a/C/program-25/a.out b/C/program-25/a.out deleted file mode 100755 index 83930e91..00000000 Binary files a/C/program-25/a.out and /dev/null differ diff --git a/C/program-25/readme.txt b/C/program-25/readme.txt new file mode 100644 index 00000000..5519cbfa --- /dev/null +++ b/C/program-25/readme.txt @@ -0,0 +1,6 @@ +This program is to print the number of *. Example if user enter 5. Then it'll print +* +** +*** +**** +***** diff --git a/C/program-26/a.out b/C/program-26/a.out deleted file mode 100755 index 8a517270..00000000 Binary files a/C/program-26/a.out and /dev/null differ diff --git a/C/program-27/a.out b/C/program-27/a.out deleted file mode 100755 index 447dbe46..00000000 Binary files a/C/program-27/a.out and /dev/null differ diff --git a/C/program-28/a.out b/C/program-28/a.out deleted file mode 100755 index b78b3ff4..00000000 Binary files a/C/program-28/a.out and /dev/null differ diff --git a/C/program-29/a.out b/C/program-29/a.out deleted file mode 100755 index fa643187..00000000 Binary files a/C/program-29/a.out and /dev/null differ diff --git a/C/program-30/a.out b/C/program-30/a.out deleted file mode 100755 index db007813..00000000 Binary files a/C/program-30/a.out and /dev/null differ diff --git a/C/program-31/a.out b/C/program-31/a.out deleted file mode 100755 index 22b5b248..00000000 Binary files a/C/program-31/a.out and /dev/null differ diff --git a/C/program-31/program.c b/C/program-31/program.c index 43a5fffb..c5dc115d 100644 --- a/C/program-31/program.c +++ b/C/program-31/program.c @@ -14,9 +14,9 @@ int main() { printf("Enter the details of student - %d\n",i); printf("Enter the name of the student\n"); - scanf("%s",&stud[i].n); + scanf("%s",stud[i].n); printf("Enter USN\n"); - scanf("%s",&stud[i].u); + scanf("%s",stud[i].u); printf("Enter total marks\n"); scanf("%d",&stud[i].m); } @@ -27,9 +27,9 @@ int main() } printf("Enter the details of new student\n"); printf("Enter the name\n"); //preferred to enter equal length of name - scanf("%s",&stud2.n); + scanf("%s",stud2.n); printf("Enter the USN\n"); - scanf("%s",&stud2.u); + scanf("%s",stud2.u); printf("Enter the marks\n"); scanf("%d",&stud2.m); printf("enter position\n"); diff --git a/C/program-32/program.c b/C/program-32/program.c index 26b3f3e9..ca73dc86 100644 --- a/C/program-32/program.c +++ b/C/program-32/program.c @@ -7,16 +7,16 @@ int m; }stud[10],stud2; int main() { - int n,i,p=0; + int n,i=0; printf("Enter the number of student\n"); scanf("%d",&n); for(i=1;i<=n;i++) { printf("Enter the details of student - %d\n",i); printf("Enter the name of the student\n"); - scanf("%s",&stud[i].n); + scanf("%s",stud[i].n); printf("Enter USN\n"); - scanf("%s",&stud[i].u); + scanf("%s",stud[i].u); printf("Enter total marks\n"); scanf("%d",&stud[i].m); } diff --git a/C/program-33/program.c b/C/program-33/program.c index 80f7131f..6ca274d2 100644 --- a/C/program-33/program.c +++ b/C/program-33/program.c @@ -1,6 +1,7 @@ /* Arithematic operation using pointers */ #include -void main() +#include +int main() { int a,b; int *x,*y; @@ -9,6 +10,6 @@ x=&a; y=&b; //s=; printf("%d\t%d",*x+*y,abs(*x-*y)); - +return 0; } diff --git a/C/program-37/a.out b/C/program-37/a.out deleted file mode 100755 index 2dff926d..00000000 Binary files a/C/program-37/a.out and /dev/null differ diff --git a/C/program-37/program.c b/C/program-37/program.c index 0f2f59a1..6be02495 100644 --- a/C/program-37/program.c +++ b/C/program-37/program.c @@ -11,15 +11,13 @@ int f; if(n==0 || n==1) { - - return ; + return 1; } else { f=fib(n-2)+fib(n-1); } - - + return f; } int main() diff --git a/C/program-38/a.out b/C/program-38/a.out deleted file mode 100755 index 0bb435f1..00000000 Binary files a/C/program-38/a.out and /dev/null differ diff --git a/C/program-38/program.c b/C/program-38/program.c index 02f4e88d..1a771155 100644 --- a/C/program-38/program.c +++ b/C/program-38/program.c @@ -11,15 +11,13 @@ int f; if( n==1) { - - return ; + return 1; } else { f=n*fact(n-1); } - - + return f; } int main() diff --git a/C/program-39/a.out b/C/program-39/a.out deleted file mode 100755 index 4ebdcb8d..00000000 Binary files a/C/program-39/a.out and /dev/null differ diff --git a/C/program-39/program.c b/C/program-39/program.c index 1d0f60f9..8bbcd1a1 100644 --- a/C/program-39/program.c +++ b/C/program-39/program.c @@ -7,7 +7,6 @@ Program to find the GCD of a number using recursion int gcd(int a,int b) { -int f; if( b!=0) { @@ -16,7 +15,7 @@ int f; } else { - return; + return a; } diff --git a/C/program-40/program.c b/C/program-40/program.c index f48a3382..d0d11ff5 100644 --- a/C/program-40/program.c +++ b/C/program-40/program.c @@ -8,7 +8,8 @@ int ack(int m,int n) else if(m!=0 && n==0) return ack(m-1,1); else if (m!=0 && n!=0) - return ack(m-1,ack(m,n-1)); + return ack(m-1,ack(m,n-1)); + return 0; } int main() diff --git a/C/program-42/program42.c b/C/program-42/program.c similarity index 94% rename from C/program-42/program42.c rename to C/program-42/program.c index 5a6154b0..3dd7b554 100644 --- a/C/program-42/program42.c +++ b/C/program-42/program.c @@ -1,7 +1,7 @@ /*C Program to print Floyd’s triangle*/ // Without using a temporary variable and with only one loop #include -void floyd(n){ +void floyd(int n){ int i,j=1; for (i=1;i<=(n*(n+1))/2;i++){ printf("%d ",i); diff --git a/C/Program-43/program.c b/C/program-43/program.c similarity index 100% rename from C/Program-43/program.c rename to C/program-43/program.c diff --git a/C/program-44/program.c b/C/program-44/program.c index 24dbbcb7..4b686c63 100644 --- a/C/program-44/program.c +++ b/C/program-44/program.c @@ -5,7 +5,7 @@ // Alphabet Z Pattern void alphabet_Z_Pattern(int N) { - int index, side_index, size; + int index, side_index; // Declaring the values of Right, // Left and Diagonal values diff --git a/C/program-47/Readme.md b/C/program-47/Readme.md new file mode 100644 index 00000000..dccb21a0 --- /dev/null +++ b/C/program-47/Readme.md @@ -0,0 +1,13 @@ +Program 47 + +Write a program to find the maximum and minimum element in an array. + +Variable description-- + +n=Number of elements in an array + +a=Array of size N + +min= Holds the minimum element + +max=Holds the maximum element diff --git a/C/program-47/kaprekar_number.c b/C/program-47/kaprekar_number.c new file mode 100644 index 00000000..37f77482 --- /dev/null +++ b/C/program-47/kaprekar_number.c @@ -0,0 +1,42 @@ +/* A kaprekar number is a number in base 10 whose square can be split such that the the sum of those numbers +add up to the original number for eg : (45)^2 = 2025 => 20+25=45 */ + + # include + # include + # include + # include + bool iskaprekarnum(int n) + { + if (n == 1) // If the number passed is 1 then it is also considered to be a kaprekar number + return true; + int square_number = n * n; // Finding the square + int count_digits = 0; //This will be the counter variable for the number of digits in the number + while (square_number != 0) + { + count_digits++; + square_number /= 10; + } + square_number = n*n; // Recalculating square as it was changed in the above while loop + for (int r_digits=1; r_digits +int main() +{ + + int a[100],n,min,max; + printf("enter the size of the array"); + scanf("%d",&n); + printf("enter the elements of the array"); + for(int i=0;imax) + max=a[i]; + if(a[i] + +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-50/Readme.md b/C/program-50/Readme.md new file mode 100644 index 00000000..06f7c7e1 --- /dev/null +++ b/C/program-50/Readme.md @@ -0,0 +1,13 @@ +Program 50 + +Write a program to check whether a given number is a palindrome or not. + +Variable description-- + +n=Holds the element which is to be checked + +temp=Holds the copy of the element + +rev= Holds the reverse of the number + +rem=Holds the digits of the number diff --git a/C/program-50/program.c b/C/program-50/program.c new file mode 100644 index 00000000..0bd7302c --- /dev/null +++ b/C/program-50/program.c @@ -0,0 +1,19 @@ +#include +int main() +{ + int rem,rev=0,temp,n; + printf("Enter the number"); + scanf("%d",&n); + temp=n; + while(n>0) + { + rem=n%10; + n=n/10; + rev=rem+(rev*10); + } + if(temp==rev) + printf("number is palindrome"); + else + printf("number is not palindrome"); + return 0; +} 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/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/read.md b/C/program-55/read.md new file mode 100644 index 00000000..42d8c087 --- /dev/null +++ b/C/program-55/read.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/READEME.md b/C/program-57/READEME.md new file mode 100644 index 00000000..6d1d4966 --- /dev/null +++ b/C/program-57/READEME.md @@ -0,0 +1,4 @@ +Program 57 + + +Write a program in C to calculate the grade 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/Java/program-1/README.md b/Java/program-1/README.md new file mode 100644 index 00000000..5bf7551a --- /dev/null +++ b/Java/program-1/README.md @@ -0,0 +1,9 @@ +Program 1 + +Write a program to find the maximum and minimum element in an array. + +Variable description-- +N=Number of elements in an array +arr=Array of size N +min= Holds the minimum element +max=Holds the maximum element \ No newline at end of file diff --git a/Java/program-1/program.java b/Java/program-1/program.java new file mode 100644 index 00000000..8abc89cd --- /dev/null +++ b/Java/program-1/program.java @@ -0,0 +1,24 @@ +import java.util.*; +import java.io.*; + +class prg { + public static void main (String[] args) { + Scanner sc=new Scanner(System.in); + System.out.println("Enter the size of array"); + int N=sc.nextInt(); + int arr[]=new int[N]; + System.out.println("Enter the elements in the array"); + for(int i=0;imax) + max=arr[i]; + } + System.out.println("Minimum="+min+"\nMaximum="+max); + } +} \ No newline at end of file diff --git a/Javascript/program-1/program-1.html b/Javascript/program-1/program-1.html new file mode 100644 index 00000000..d47acfbb --- /dev/null +++ b/Javascript/program-1/program-1.html @@ -0,0 +1,21 @@ + + +SUM OF THE TWO NUMBERS + + +
+ENTER NUMBER1:
+ENTER NUMBER2:
+Submit: +Reset: +
+ + diff --git a/Javascript/program-1/read.md b/Javascript/program-1/read.md new file mode 100644 index 00000000..a0b76fea --- /dev/null +++ b/Javascript/program-1/read.md @@ -0,0 +1,2 @@ +# Program-1 +## This is a javascript program for adding two numbers diff --git a/Javascript/program-2/program-2.html b/Javascript/program-2/program-2.html new file mode 100644 index 00000000..531f4181 --- /dev/null +++ b/Javascript/program-2/program-2.html @@ -0,0 +1,16 @@ + + + CHARACTER PROCESSING METHODS + + + + + diff --git a/Javascript/program-2/read.md b/Javascript/program-2/read.md new file mode 100644 index 00000000..39f1e330 --- /dev/null +++ b/Javascript/program-2/read.md @@ -0,0 +1,2 @@ +# Program-2 +## This is a javascript program for string operations diff --git a/Javascript/program-3/armstrong.html b/Javascript/program-3/armstrong.html new file mode 100644 index 00000000..fe1188a2 --- /dev/null +++ b/Javascript/program-3/armstrong.html @@ -0,0 +1,20 @@ + +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/palindrome.html b/Javascript/program-4/palindrome.html new file mode 100644 index 00000000..52145b20 --- /dev/null +++ b/Javascript/program-4/palindrome.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/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-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/index.html b/index.html index 19b9c3d4..142e7e1b 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,16 @@ - - + + + Basic Programs -

BASIC PROGRAMS

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

Basic Programs

+

Basic programs in C and Python

+
+ + diff --git a/readme.md b/readme.md index b41b556d..25413caa 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ # Basic programs -## This repo contains basics programs in c programming language and python. +## 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/css/index.css b/src/css/index.css new file mode 100644 index 00000000..e69de29b diff --git a/src/images/1.jpg b/src/images/1.jpg new file mode 100644 index 00000000..a7aa7071 Binary files /dev/null and b/src/images/1.jpg differ diff --git a/src/js/index.js b/src/js/index.js new file mode 100644 index 00000000..e69de29b