OpenMP, Parallel Programming in C [Intro]

This is a post in which you will get the basic knowledge about the parallel programming concept. In this post we going to use the OpenMP model. This program is implemented in the C Language. Basically this programs demonstrates how the thread gets executed in different Cores of the processor. In this case, this program is executed in a Quad Core CPU, so it displays 4 threads from 0-3. Screenshots[Demo] Here the threads are executed randomly on each cores on the basics of their availability. This method by which threads…

Read More

Hackerrank Caeser Cipher Solution

The below program is the solution of Caeser Cipher in implementation domain. You can get the program HERE. Output :  Code : #include<iostream>using namespace std;int main(){ int x,t,m; cin>>x; string s; cin>>s; cin>>t; while(t>26) { t=t-26; } for(int i=0;i<s.length();i++) { m=s[i]+t; if(islower(s[i])) { if(m>122) { m=m-122; m+=96; } } else if(isupper(s[i])) { if(m>90) { m=m-90; m+=64; } } //cout<<m; if(isalpha(s[i])) cout<<(char)m; else cout<<s[i]; } return 0;}

Read More

Non Restoring Division Algorithm Implementation in C

This  is a Dynamic program for the implementation of the NON RESTORING Division Algorithm in C Language. Non Restoring Division uses Left Shift Operations, Twos’ Compliment and Binary Addition. Screenshots[Demo] The Code #include<stdio.h>#include<malloc.h>int *a,*q,*m,*mc,*c,n,d;int powr(int x,int y){ int s=1,i; for(i=0;i<y;i++) s=s*x; return s;}void print(int arr[],int n){ int i; for(i=0;i<n;i++) printf(“%d “,arr[i]);}void bin(int n, int arr[]){ int r, i = 0; do{ r = n % 2; n /= 2; arr[i] = r; i++; }while(n > 0); }void set(int array[], int x){ int i,tmp[20]={0}; for(i = x -1; i >=0; i–)…

Read More

Binary Multiplication in C

This is a dynamic program which accepts two integer from the console and convert them to Binary Numbers.After converting them, they are multiplied by repetitive addition and the result is then displayed in the console !Binary Multiplication is highly necessary because computer only understands the addition. In case of multiplication it’s repetitive addition. Screenshots [Demo] The Code: #include<stdio.h>#include<malloc.h>int *q,*m,*c,n,d,siz;int powr(int x,int y){ int s=1,i; for(i=0;i<y;i++) s=s*x; return s;}void bin(int n, int arr[]){ int r, i = 0; do{ r = n % 2; n /= 2; arr[i] = r; i++;…

Read More

Restoring Division Algorithm Implementation In C

This is a dynamic program for the implementation of the Restoring division Algorithm in the C.Restoring Division uses Left Shift Operations, Twos’ Compliment and Binary Addition. Screenshots [Demo]: The Code #include<stdio.h>#include<malloc.h>int *a,*q,*m,*mc,*c,n,d;int powr(int x,int y){ int s=1,i; for(i=0;i<y;i++) s=s*x; return s;}void print(int arr[],int n){ int i; for(i=0;i<n;i++) printf(“%d “,arr[i]);}void bin(int n, int arr[]){ int r, i = 0; do{ r = n % 2; n /= 2; arr[i] = r; i++; }while(n > 0); }void set(int array[], int x){ int i,tmp[20]={0}; for(i = x -1; i >=0; i–) tmp[x-1-i]=array[i]; for(i=0;i<x;i++)…

Read More

Shuffle the characters of a string in Java

This is a program which accepts a string using the BufferdReader and InputStreamReader class, and then shuffle the characters present inside the string and generate a new string which is displayed in the console. Basically the characters of the string are stored in a Character List using the for each loop. Then the characters in that list is randomly removed and appended in a StringBuilder object output. Screenshots [Demo] The Code: import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.Collections;import java.util.List;import java.util.Random;class Brain{ public static void main(String []as)throws IOException { BufferedReader br=new BufferedReader(new…

Read More

Binary Addition in C

This is a dynamic program which accepts two integer from the console and convert them to Binary Numbers.After converting them, they are added and the result is then displayed in the console ! Binary addition is highly necessary because computer only understands the addition.  Whether in case of  multiplication it’s repetitive addition, in case of  division it is repetitive division and for subtraction it is the addition of the two’s compliment of the other number. Screenshots [DEMO] The Code: #include<stdio.h>#include<malloc.h>int *q,*m,*c,n,d,siz;int powr(int x,int y){ int s=1,i; for(i=0;i<y;i++) s=s*x; return s;}void…

Read More

Selection Sort Using C

                   Hello guys, selection sort is one of the basic algorithm and programming concept which we need from the very beginning to lifetime of programming. In most of the cases in programming, we need sorted input for the execution of the code in proper manner. But its not a logical habit to ask the use to enter in the sorted manner. So this is one of the basic sorting concept one should know. Description:                …

Read More

Create 1+2=3 Android Game

This post will guide you to create a highly interactive 1+2=3 Game. This game is based on a simple logic. Basically you have 3 number 1,2,3 which will be shuffled each time with a randomly generated operator (+,-,*,/) placed in between. Screenshots: Lets go through important section of the project. Code for fetching Highscore : public int chec() { SQLiteDatabase SQLiteDb = mh.getWritableDatabase(); String [] col1 = {“_id”,”score”}; int ch=0; Cursor cu1 = SQLiteDb.query(“scr”, col1, null, null, null, null, null); while(cu1.moveToNext()) { ch=Integer.parseInt(cu1.getString(1)); } return ch; } Code For Generating…

Read More