├── C ├── Arrays │ ├── 2D array.c │ ├── Greatest.c │ └── README.md ├── README.md ├── basics │ ├── Program02.c │ ├── README.md │ ├── prefix and postfix.c │ ├── program03.c │ ├── program04.c │ ├── program05.c │ ├── program06.c │ ├── program07.c │ └── program08.c ├── grade calculation.c └── program09.c ├── Datastructures └── README.md ├── Java ├── Basic │ ├── Hello.java │ └── README.md ├── README.md ├── Strings │ ├── PalindromicSubstrings.java │ ├── PrintAllTheSubstringsOfAString.java │ ├── PrintWithASCIIDiff.java │ ├── RemovePrimeNumbersFromAList.java │ ├── StringCompression.java │ ├── StringVsStringBuilder.java │ └── ToggleCase.java └── patterns │ ├── PatternFive.java │ ├── PatternFour.java │ ├── PatternOne.java │ ├── PatternThree.java │ └── PatternTwo.java ├── LICENSE ├── Python ├── FindHashOfFile.py ├── FindSizeOrResolutionOf.py ├── README.md └── ShuffleDeckOfCards.py └── README.md /C/Arrays/2D array.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | int a[3][3]={1,2,3,4,5,6,7,8,9}; 5 | int i,j; 6 | printf("elements in an array\n"); 7 | for(i=0;i<=2;i++) 8 | for(j=0;j<=2;j++) 9 | printf("%d\n",a[i][j]); 10 | printf("elements in tabular form\n"); 11 | for(i=0;i<=2;i++) 12 | { 13 | printf("\n"); 14 | for(j=0;j<=2;j++) 15 | printf("%d\t",a[i][j]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /C/Arrays/Greatest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | main() 4 | { 5 | int a[10],i,max; 6 | printf("enter the 10 numbers\n"); 7 | for(i=0;i<=9;i++) 8 | scanf("%d",&a[i]); 9 | max=a[0]; 10 | for(i=1;i<=9;i++) 11 | if(max 2 | int main() 3 | { 4 | int n; 5 | printf("enter the number\n"); 6 | scanf("%d",&n); 7 | printf("display the integer number and the number is %d",n); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /C/basics/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /C/basics/prefix and postfix.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a=5,x; 5 | x=a++ + ++a + --a + ++a + ++a + a++ + ++a + ++a; 6 | // x=++a; 7 | printf("%d\n%d",x,a); 8 | } 9 | -------------------------------------------------------------------------------- /C/basics/program03.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n1,n2,add; 5 | printf("enter the 1st nnd 2nd number\n"); 6 | scanf("%d%d",&n1,&n2); 7 | add=n1+n2; 8 | printf(" %d + %d =%d",n1,n2,add); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /C/basics/program04.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int n; 4 | printf("enter a number\n"); 5 | scanf("%d",&n); 6 | { 7 | 8 | if(n%2==0) 9 | 10 | printf("%d is even\n",n); 11 | else 12 | printf("%d is odd\n",n); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /C/basics/program05.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n1,n2,add,sub,mul,div; 5 | printf("enter the 1st nnd 2nd number\n"); 6 | scanf("%d%d",&n1,&n2); 7 | add=n1+n2; 8 | printf(" %d + %d =%d\n",n1,n2,add); 9 | sub=n1-n2; 10 | printf(" %d - %d =%d\n",n1,n2,sub); 11 | mul=n1*n2; 12 | printf(" %d * %d =%d\n",n1,n2,mul); 13 | div=n1/n2; 14 | printf(" %d / %d =%d\n",n1,n2,div); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /C/basics/program06.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | char c,lc,uc; 5 | printf("enter alphabet"); 6 | scanf("%c",&c); 7 | lc=(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'); 8 | uc=(c=='A'||c=='E'||c=='I'||c=='O'||c=='U'); 9 | if(lc||uc) 10 | printf("this alphabet is a vowel\n"); 11 | else 12 | printf("this alphabet is a consonent\n"); 13 | } 14 | -------------------------------------------------------------------------------- /C/basics/program07.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | int x; 5 | printf("enter a year"); 6 | scanf("%d",&x); 7 | if(x%100==0) 8 | { 9 | if(x%400==0) 10 | printf("leap"); 11 | } 12 | else 13 | if(x%4==0) 14 | printf("leap"); 15 | else 16 | printf("not leap year"); 17 | } 18 | -------------------------------------------------------------------------------- /C/basics/program08.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | int n,y=0,r; 5 | printf("enter a number"); 6 | scanf("%d",&n); 7 | while(n!=0) 8 | { 9 | r=n%10; 10 | y=y+r; 11 | n=n/10; 12 | } 13 | printf("add of digits%d",y); 14 | } 15 | -------------------------------------------------------------------------------- /C/grade calculation.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | float mark; 5 | 6 | printf("enter the mark of the student"); 7 | scanf("%f",&mark); 8 | if(mark>=90 && mark<=100) 9 | printf("grade 0"); 10 | else if(mark>=80 && mark<=90) 11 | printf("grade E"); 12 | else 13 | printf("fail"); 14 | } 15 | -------------------------------------------------------------------------------- /C/program09.c: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | int fact=1,n,i=1; 5 | printf("enter a number"); 6 | scanf("%d",&n); 7 | while(i<=n) 8 | { 9 | fact=fact*i; 10 | i++; 11 | } 12 | printf("factorial of a number %d = %d",n,fact); 13 | } 14 | -------------------------------------------------------------------------------- /Datastructures/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Java/Basic/Hello.java: -------------------------------------------------------------------------------- 1 | #Wap to to dispaly "Hello world" in java. 2 | class student 3 | { 4 | public static void main(String args[]) 5 | { 6 | System.out.println("Hello"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Java/Basic/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Java/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Java/Strings/PalindromicSubstrings.java: -------------------------------------------------------------------------------- 1 | package easy.strings; 2 | import java.util.*; 3 | 4 | public class PalindromicSubstrings { 5 | //checking for the palindrome 6 | public static boolean isPalindrome(String s) 7 | { 8 | int i = 0; 9 | int j = s.length() -1; 10 | while(i<=j){ 11 | char ch1 = s.charAt(i); 12 | char ch2 = s.charAt(j); 13 | if(ch1 != ch2){ 14 | return false; 15 | } 16 | else{ 17 | i++; 18 | j--; 19 | } 20 | } 21 | return true; 22 | } 23 | //printing the al the substrings 24 | public static void solution(String str){ 25 | //write your code here 26 | for(int i = 0; i al){ 17 | // write your code here 18 | 19 | for(int i = al.size() - 1 ; i>=0 ;i--){ 20 | int val = al.get(i); 21 | if(isPrime(val) == true){ 22 | al.remove(i); 23 | } 24 | 25 | } 26 | } 27 | public static void main(String[] args) { 28 | Scanner scn = new Scanner(System.in); 29 | int n = scn.nextInt(); 30 | ArrayList al = new ArrayList(); 31 | for(int i = 0 ; i < n; i++){ 32 | al.add(scn.nextInt()); 33 | } 34 | solution(al); 35 | System.out.println(al); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Java/Strings/StringCompression.java: -------------------------------------------------------------------------------- 1 | package easy.strings; 2 | import java.util.*; 3 | 4 | public class StringCompression { 5 | public static String compression1(String str){ 6 | // write your code here 7 | String s = str.charAt(0)+""; 8 | 9 | for(int i = 1 ; i < str.length() ;i++) 10 | { 11 | char curr = str.charAt(i); 12 | char prev = str.charAt(i-1); 13 | if(curr != prev){ 14 | s += curr; 15 | } 16 | } 17 | 18 | return s; 19 | } 20 | 21 | public static String compression2(String str){ 22 | // write your code here 23 | String s = str.charAt(0)+""; 24 | int count = 1; 25 | 26 | for(int i = 1 ; i < str.length() ;i++) 27 | { 28 | char curr = str.charAt(i); 29 | char prev = str.charAt(i-1); 30 | if(curr == prev){ 31 | count++; 32 | } 33 | else{ 34 | if(count > 1){ 35 | s += count ; 36 | count = 1; 37 | } 38 | s +=curr; 39 | } 40 | } 41 | if(count > 1) 42 | { 43 | s += count ; 44 | count = 1; 45 | } 46 | 47 | return s; 48 | } 49 | public static void main(String[] args) { 50 | Scanner scn = new Scanner(System.in); 51 | String str = scn.next(); 52 | System.out.println(compression1(str)); 53 | System.out.println(compression2(str)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Java/Strings/StringVsStringBuilder.java: -------------------------------------------------------------------------------- 1 | package easy.strings; 2 | 3 | public class StringVsStringBuilder { 4 | public static void main(String[] args) { 5 | int n = 1000000; 6 | long start = System.currentTimeMillis(); 7 | /**String s =""; 8 | for (int i = 0 ;i = 'a' && ch <= 'z'){ 9 | ans.append((char)(ch - 'a' + 'A') + ""); 10 | }else{ 11 | ans.append((char)(ch - 'A' +'a') + ""); 12 | } 13 | } 14 | return ans.toString(); 15 | } 16 | public static void main(String[] args) { 17 | Scanner scn = new Scanner(System.in); 18 | String str = scn.next(); 19 | System.out.println(toggleCase(str)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Java/patterns/PatternFive.java: -------------------------------------------------------------------------------- 1 | package easy.patterns; 2 | 3 | public class PatternFive { 4 | public static void main(String[] args){ 5 | Scanner scn = new Scanner(System.in); 6 | int n = scn.nextInt(); 7 | 8 | for( int i = 0; ii ;j--){ 9 | System.out.print("* "+"\t"); 10 | } 11 | System.out.println(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Kushal Das 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Python/FindHashOfFile.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | def hash_file(filename): 3 | h = hashlib.sha1() 4 | with open(filename,'rb') as file: 5 | 6 | 7 | chunk = 0 8 | while chunk != b'': 9 | 10 | chunk = file.read(1024) 11 | h.update(chunk) 12 | 13 | 14 | return h.hexdigest() 15 | 16 | message = hash_file("track1.mp3") 17 | print(message) 18 | -------------------------------------------------------------------------------- /Python/FindSizeOrResolutionOf.py: -------------------------------------------------------------------------------- 1 | def jpeg_res(filename): 2 | 3 | with open(filename,'rb') as img_file: 4 | img_file.seek(163) 5 | 6 | 7 | a = img_file.read(2) 8 | height = (a[0] << 8) + a[1] 9 | a = img_file.read(2) 10 | 11 | 12 | width = (a[0] << 8) + a[1] 13 | 14 | print("The resolution of the image is",width,"x",height) 15 | 16 | jpeg_res("img1.jpg") 17 | -------------------------------------------------------------------------------- /Python/README.md: -------------------------------------------------------------------------------- 1 | HERE ARE THE LIST OF SOME PYTHON PROGRAMS : 2 | 3 | 1) Python Program to find the SHA-1 message digest of a file . 4 | 2) Program to Find the Size (Resolution) of a Image . 5 | 3) Program to shuffle a deck of card . 6 | -------------------------------------------------------------------------------- /Python/ShuffleDeckOfCards.py: -------------------------------------------------------------------------------- 1 | import itertools, random 2 | 3 | 4 | deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club'])) 5 | 6 | 7 | random.shuffle(deck) 8 | 9 | 10 | print("You got:") 11 | for i in range(5): 12 | print(deck[i][0], "of", deck[i][1]) 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Programming-Imp-Questions 2 | This Repo. contains all important questions in any programming language 3 | --------------------------------------------------------------------------------