Posts

C program of Cyclic Redundancy Check

Image
C program of Cyclic Redundancy Check    Program #include <stdio.h> // shorthand for loops #define forn(i,e) for(int i = 0; i < e; i++) #define forsn(i,s,e) for(int i = s; i < e; i++) int validate_data( int len_data, int data[], int len_divisor, int divisor[]){ // Returns 1, if the data is correct // Returns 0, if the data is incorrect/corrupted. int current_bits[len_divisor]; forn(i, len_divisor) { current_bits[i] = data[i]; } // the logic is same as generating the crc. forn(i, len_data) { if (!current_bits[ 0 ]) { forn(j, len_divisor- 1 ) { current_bits[j] = current_bits[j+ 1 ]; } current_bits[len_divisor- 1 ] = data[i+len_divisor]; } else { forn(j, len_divisor) { current_bits[j] = current_bits[j]^divisor[j]; } forn(j, len_divisor- 1 ) { current_bits[j] = current_bits[j+ 1 ]; } current_bits[len_divisor- 1 ]

Java program to play Rock, Paper and Scissors with computer.

Image
import java.lang.*; import java.util.Scanner; import java.util.Random; public class RPS{          public int user_score =0 , comp_score = 0;     public String user_choice, comp_choice;     Random ran;     Scanner scan;     public RPS(){         ran = new Random();         scan = new Scanner(System.in);     }     public void userTurn(){         System.out.println("\n[1] Rock , [2] Paper , [3] Scissors");         System.out.print("Choice > ");         user_choice = whatIsIt(scan.nextInt() - 1);     }     public void machineTurn(){         comp_choice = whatIsIt(ran.nextInt(3) + 1);     }     public String whatIsIt(int a){         if(a==0){             return "Rock";         }         if(a==1){             return "Paper";         }         return "Scissors";     }     public String whoKilled(){         if(user_choice!= comp_choice){             if(user_choice== "Rock"){                 if(comp_choice == "Paper"){   

How to convert char to int number in C language ?

Image
To Convert char(Character) Number to int (Integer) in C Language   Char - > Int

Build Your Algo | Practice Coding | Programming Language |

Image
  BUILD YOUR ALGORITHM  CODE !           ( Any programming language ,  Build in any logic  , Practice Coding)

JAVA | Check by ASCII weather a single input character is vowel or consonant?

Image
PRACTICE AND LEARN  JAVA                          (ASCII, Input a character)

Prime Number | Check | Intervals | Python Language

Image
Print the prime numbers in given two intervals :  (coded in Python Language)

Counter() | Collection library | Python Langauage

                Learn and Practice :