Send note as E-Mail from PC application using JAVA

Hi guys. This is my first post using my home management system. Here i am going to post codes on making a simple app that can be used to send email with notes to your own mail. this comes handy when you are working on office or other PC and you want to save something interesting, In that scenario hopefully you will not be interested to open your mobile and get on typing. Hope this helps. But to use this you need to enable IMAP and POP in your mail…

Read More

Hackerrank Utopian Tree Solution

This is the solution to the program in Hackerrank. This program can be found in the Algorithm Domain. Basically the Utopian Tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.  Screenshot The Code: #include<stdio.h>int main() { int t, n, a; scanf(“%d”, &t); while(t–) { a=1; scanf(“%d”, &n); for(int i=1; i<=n; i++) { if(i%2) a<<=1; else a++; } printf(“%dn”, a); } return 0;}…

Read More

Simple Factorial program for larger numbers

It is a totally different approach, we are just playing with double.As we know double has very large value 4.9e-324 to 1.8e+308.Then we convert the double into an integer array. Screenshot: OUTPUT The Code: #include<iostream>#include<stdlib.h>#include<math.h>using namespace std;/*Classic factorial function to find the factorial of a number using recursion method*/double factorial(int n){ if(n==1) return 1; else return (factorial(n-1)*n);}int main(){ int n; cout<<“factorial of: “; cin>>n; double r = factorial(n); double s = r; int i=0; /*to find the number of digits of the answer*/ for(i=0; r>=1; i++) { r /= 10;…

Read More

Bubble Sort In Python

This is a simple program which demonstrates the implementation of the bubble sort algorithm in python. The complexity of the program is O(n2) . The Input is taken from the console and then appended to a list, which is further processed . Output Screen: Program : print ‘Enter the list of elements followed by space:’x=raw_input();x=map(int,x.split())for i in range(0, len(x)-1): for j in range(0,len(x)-i-1): if(x[j]>x[j+1]): swp=x[j] x[j]=x[j+1] x[j+1]=swpprint x Found suggestions, Please comment them here !

Read More

Binary Search using Java

It is a technique to search an element in sorted array. In this type of search half of the array is ignored just after one comparison. Each time required element is compared with middle element of the array and range is decided . Best Case Performance :  O(1)Average Case Performance : O(log n)Worst Case Performance : O(log n)Demo Output: The Program import java.util.Scanner; public class BinarySearch1 { public static void main(String args[]) { int i, first=0, last, mid, no, element; Scanner s = new Scanner(System.in); System.out.println(“n How many elements:”); no=…

Read More

User Defined Exceptions in Java

In this post you will learn to create your own, user defined exceptions. This program will handle unchecked exceptions, i.e those exceptions which cannot be checked by the compiler, or the run time exceptions. In this program there is a simple class AgeMargin in which when the age is less then 18 or greater then 24 generates an AgeException. Screenshots[Demo] The Code: import java.util.Scanner;class AgeException extends Exception{  public String toString()  {    return “AgeException Caught!”;  }}public class AgeMargin {  public static void main(String []args)  {    int age;    Scanner…

Read More

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