Posts

Finding the maximum element in a list:

For finding the maximum element in a list: // C++ program to demonstrate the use of std::max #include<iostream> #include<algorithm> using namespace std; // Defining the binary function bool comp(int a, int b) {  return (a < b); } int main() {   int a=10;   int b=20;   int c=30;   int d=40;   int e=50;  // Finding the largest of all the numbers  cout << std::max({a, b, c, d, e},comp) << "\n"; return 0; } 

For loop C++

A  for  loop is a programming language statement which allows code to be repeatedly executed. The syntax for this is for ( <expression_1> ; <expression_2> ; <expression_3> ) <statement> expression_1  is used for intializing variables which are generally used for controlling terminating flag for the loop. expression_2  is used to check for the terminating condition. If this evaluates to false, then the loop is terminated. expression_3  is generally used to update the flags/variables. A sample loop will be for(int i = 0; i < 10; i++) { ... } Input Format You will be given two positive integers,   and   ( ), separated by a newline. Output Format For each integer   in the interval   : If  , then print the English representation of it in lowercase. That is "one" for  , "two" for  , and so on. Else if   and it is an even number...

Blockchain-program(easy)

A simple and very old method of sending secret messages is the substitution cipher. You might have used this cipher with your friends when you were a kid. Basically, each letter of the alphabet gets replaced by another letter of the alphabet. For example, every 'a' get replaced with an 'X', and every 'b' gets replaced with a 'Z', etc. Write a program thats ask a user to enter a secret message. Encrypt this message using the substitution cipher and display the encrypted message. Then decryped the encrypted message back to the original message. You may use the 2 strings below for  your subsitition. For example, to encrypt you can replace the character at position n in alphabet with the character at position n in key. To decrypt you can replace the character at position n in key with the character at position n in alphabet. Have fun! And make the cipher stronger if you wish! Currently the cipher only substitutes letters - you could easily...

Kotlin basics_habijabi -variable to hashmap

Kotlin basics_habijabi fun main(args : Array ) { // println("Enter a  Number") //    var x:Int=readLine()!!.toInt() // println("Enter a  Number") //    var y:Int=readLine()!!.toInt() // println(x+y) // // println("Enter number") // var x:Int=readLine()!!.toInt() // // when(x) // { // 1->println("A") // 2->println("B") // in 3..5 -> println("C") // // else -> println("D") // // } //var x:Int // while(x<=5){ // println(x) // x++ // } // for(x in 1..10){ // print(x) // print(" ") // } // // println() // // for(y in 10 downTo 1){ // print(y) // print(" ") // } // println() // for( z in 1..10 step 3){ // print(z) // print(" ") // } var bloodGroup=arrayOf("sifat","abc","def") for( x in bloodGroup) println(x) println(bloodGroup[0]) var bo...

Bubble Sort Algorithm in java

Image
Bubble Sort Algorithm package one; public class One { public static void main(String[] args) { // TODO Auto-generated method stub int[] intArray= {20,35,-15,7,55,1,-27}; for(int lastUnsortedIndex=intArray.length-1;lastUnsortedIndex >0;lastUnsortedIndex--) { for(int i=0;i<lastUnsortedIndex;i++) { if(intArray[i]>intArray[i+1]) { swap(intArray,i,i+1); } } } for(int i=0;i<intArray.length;i++) { System.out.print(intArray[i]+"  "); } } public static void swap(int [] array,int i,int j) { if(i==j) { return; } int temp=array[i]; array[i]=array[j]; array[j]=temp; } }

StringBuffer In Java

StringBuffer In Java: package one; public class StringBuffer { public static void main(String[] args) { java.lang.StringBuffer sb=new java.lang.StringBuffer("Hello ");  System.out.println(sb.capacity()); sb.append("Java"); System.out.println(sb); sb.insert(2," haha "); System.out.println(sb); sb.replace(1, 4, "huhuhuhu"); System.out.println(sb); sb.ensureCapacity(10); System.out.println(sb.capacity()); sb.delete(1, 18); System.out.println(sb); System.out.println(sb.capacity()); sb.reverse(); System.out.println(sb); }  } 

Convert LinkList To ArrayList in Java

Convert LinkList To ArrayList in Java: package one; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class LinkToArray { public static void main(String[] args) {     LinkedList<String> linkedlist = new LinkedList<String>();     linkedlist.add("Sifat");     linkedlist.add("mohaiminur"); linkedlist.add("huda"); linkedlist.add("sakib"); linkedlist.add("robi"); List<String> list = new ArrayList<String>(linkedlist); for (String str : list){    System.out.println(str); } } }

HashMap In Java

package one; import java.util.Map; public class HashMap { public static void main(String[] args) { Map<Integer,String> map=new java.util.HashMap<Integer,String>(); map.put(1,"b1"); map.put(2,"b2"); map.put(3,"b3"); for(Integer i: map.keySet()) { System.out.println(map.get(i)); } } }

Sum of digits, Reverse, Palindrome & Armstrong Number Checker

Sum of digits, Reverse, Palindrome & Armstrong Number Checker: package checker; import java.util.Scanner; public class Check { public static void main(String[] args) { int sum=0,s,temp,num,c; System.out.println("Enter any number: "); Scanner input=new Scanner(System.in); num=input.nextInt(); temp=num; System.out.println("Enter 0 for Sum of digits."); System.out.println("Enter 1 for Reverse number."); System.out.println("Enter 2 for Palindrome number."); System.out.println("Enter 3 for Armstrong number."); Scanner input0=new Scanner(System.in); System.out.println(); c=input0.nextInt(); switch(c) { case 0: {   while(temp!=0) { s=temp%10; sum=sum+s; temp=temp/10; } System.out.println("Sum of digits: "+sum); break; } case 1: { while(temp!=0) { s=temp%10; sum=sum*10+s...

জাভাতে কেন 200 == 200 ভুল , কিন্তু 100 == 100 সঠিক ?

Image
জাভাতে কেন  200 == 200 ভুল  , কিন্তু 100 == 100 সঠিক ? package sifat; import java.util.Scanner; public class Sifat { public static void main(String[] args) { Integer a = 100, b = 100; System.out.println(a == b); Integer c = 200, d = 200; System.out.println(c == d); } } Output: বিশ্লেষণঃ   ভেরিয়েবল এর মান -১২৭ থেকে ১২৭ এর ভিতর এবং যদি  ভেরিয়েবল গুলোর মান সমান থাকে তাহলে বুলিয়ান এ জাভাতে সঠিক দেখাবে । আর যদি -১২৭ থেকে ১২৭ এর চেয়ে কম বেশি হয় তাহলে ভুল দেখাবে।  যদি আপনি Integer.java দেখেন, তাহলে পাবেন যে কোনও  inner private class, যেমন   IntegerCache.java যা caches করে সব  Integer objects যার  মান -১২৭ থেকে ১২৭ এর ভিতর।

Book Store in Java

Book Store in Java:- package sifatOne; import java.util.Scanner; public class SifatTwo {//SifatTwo  class name static Scanner input=new Scanner(System.in); static String[] books= {"java","C","Python"}; static final double studentDiscount=0.3; static final double teacherDiscount=0.4; static final double alienDiscount=0.0; public static void main(String[] args) { prln("...WELCOME TO OUR BOOKSTOR..."); prln("Which book do you want? \n Ans: "); String userChoice=input.nextLine(); if(books[0].toLowerCase().equals(userChoice.toLowerCase())) { prln("you opted for "+ books[0]+" books"); calculatePrice(books[0]); }else if(books[1].toLowerCase().equals(userChoice.toLowerCase())) { prln("you opted for "+ books[1]+" books"); calculatePrice(books[1]); }else if(books[2].toLowerCase().equals(userChoice.toLowerCase())) { prln("you ...

Lighting

Lighting I saw her from a distance our of the corner of my eye her hair was shining bright she's the prettiest girl i've ever seen around I saw her from a distance she made me wanna smile her face is cute and it's beautiful and she's the only girl that stands out in the crowd I hope you notice me sometime I hope you'll be with me,be mine you're everything,you're my sunshine oh,oh,oh she's got me struck by lighting lighting and it's frightening frightening I don't ever think I'll be the same again you're my princess,my girl you're my interest,my world you mean everything everything, to me ohhh ohhh oh oh and if you smile at me you would make my heart start racing anything to see you're so amazing think i've been struck by lighting lighting and it's frightening frightening I don't ever think i'll be the same again cause i've been struck by lighting lighting and it's frightening f...

Tower of honoi in c program

Tower of honoi in c program: #include stdio.h void toh(int n,int source,int aux,int dest){ if(n==1){     printf("Move the disk from tower no: %d to tower no: %d\n",source,dest);     return;  }  toh(n-1,source, dest,aux);  toh(1,source,aux,dest);  toh(n-1,aux, source,dest); } int main() {     toh(5,1,2,3);     return 0; }

Charecter & space founder in c program

Charecter & space founder in c program: #include main() {     char str[80];     printf("Enter a string: ");     scanf("%[^\n]",str);     int i,countAlpha=0,countSpace=0;     for(i=0;str[i]!='\0';i++){         if((str[i]>='A' && str[i]<='Z')||(str[i]>='a' && str[i]<='z')){             countAlpha++;         }         else if(str[i]==' '){///else if(str[i]==32) =>==> (' '=32)             countSpace++;         }     }     printf("Total Alphabetic charecters found: %d\n",countAlpha);     printf("Total Spaces charecters found: %d\n",countSpace); }

Leap Year in c

Leap Year in c #include main() {     int year;     printf("Enter a year: ");     scanf("%d",&year);     if((year%4==0 && year%100!=0)||year%400==0){         printf("%d is a leap year",year);     }     else{         printf("%d is not a leap year",year);     }     return 0; }

Leap Year program in c language

Leap Year program in c language: #include main() {     int year;     printf("Enter year: ");     scanf("%d",&year);     if(year%4==0){         if(year%100==0){             if(year%400==0){                 printf("%d is a leap year",year);             }             else{                 printf("%d is not a leap year",year);             }         }         else{             printf("%d is a leap year",year);         }     }     else{         printf("%d is not a leap year",year);     } }

Adition all Odd & Even number from User Input

Image
 Odd Number #include main() {     int i,n,a=0;    scanf("%d",&n);     for(i=1;i<=n;i=i+2)     a=a+i;     printf("%d\n",a); } Even Number #include main() {     int i,n,a=0;     scanf("%d",&n);     for(i=0;i<=n;i=i+2)     a=a+i;     printf("%d\n",a); } Facebook

C programming: Find Vowel-Consonant Or if Other

Image
#include int main() {     char ch;     scanf("%c",&ch);     if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')     {         printf("%c is lower case vowel",ch);     }     else if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')     {     printf("%c is Upper case vowel",ch);     }     else if(ch>='a'&&ch<='z')     {         printf("%c is lower consonant",ch);     }     else if(ch>='A'&&ch<='Z')     {         printf("%c is upper consonant",ch);     }     else     {         printf("There is no english word");     }     getchar();   ...

Array student result programme in c

Image
Array student result programme in c : #include main() {     int ft[40]={41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};     int st[40]={80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41};     int fm[40]={41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61};     int i,marks,count;;     double tm[40];     for(i=0;i         tm[i]=ft[i]/4+st[i]/4+fm[i]/2;     }     for(i=1;i<=40;i++){         printf("Roll No:%d Total mark:%.0lf\n",i,tm[i-1]);     } } Output: