If you are new to programming world then you are at right place.Learning to code is not so easy task.It's not like other subjects like history geography that you can memorized and write the exam.To learn code you need only one ingredient that is your problem solving skill.

How to achieve Problem Solving Skill?

Answer: There is no readymade formula to accquire this skill.The only path to achieve problem solving skills by practicing code more and more.So here we bring some Introductory begineer to advanced level programs that will give confiedence to solve more problems.


Programs that everyone should know

We posted the solutions in 3 different languages.

Let's get Started :)

1. Print Anything


#include <stdio.h>
int main() {
   printf("Welcome to World of Geeks!");
   return 0;
}

Output:

Welcome to World of Geeks!

public class PrintAnything {
   public static void main(String[] args) {
      System.out.println("Welcome to World of Geeks!");
   }
}

Output:

Welcome to World of Geeks!

print ("Welcome to World of Geeks!")

Output:

Welcome to World of Geeks!


2. Ceil and Floor concept


Ceil returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer Floor returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.


Coming soon

import java.math.*;
import java.util.*;
public class CeilAndFloor {
   public static void main(String[] args) {
      double value=25.67;
      System.out.println("Actual value : "+value);
      System.out.println("Ceil value : "+Math.ceil(value));
      System.out.println("Floor value : "+Math.floor(value));
   }
}

Output:

Actual value : 25.67
Ceil value : 25.0
Floor value : 26.0

Coming soon


3. Sum of Digits of a number


Coming soon

public class SumofDigits
{
	public static void main(String[] args) {
	    int num=1234;
	    int result=0;
	    while(num>0){
	        result = result + (num%10);
            num/=10; 
	    }
	    System.out.println("Sum of Digits is : "+result);
	}
}

Output:

Sum of Digits is : 10

Coming soon


4. Factorial of a number


Coming soon

public class Factorial
{
	public static void main(String[] args) {
	    int num=6;
	    int result=1;
	    while(num>0){
	        result = result * num;
            num--; 
	    }
	    System.out.println("Factorial is : "+result);
	}
}

Output:

Factorial is : 720

Coming soon


5. Print reverse of a number


Coming soon

public class ReverseNum
{
	public static void main(String[] args) {
	    int num=89056;
	    int result=0;
	    while(num>0){
	        result = result * 10 + (num%10);
            num/=10; 
	    }
	    System.out.println("Reverse number is : "+result);
	}
}

Output:

Reverse number is : 65098

Coming soon


6. Fibonacci series


Coming soon

public class FiboSeries
{
	public static void main(String[] args) {
	    int num =10;
        int f1, f2=0, f3=1;
        for(int i=1;i<=num;i++)
        {
            System.out.print(" "+f3+" "); 
            f1 = f2;
            f2 = f3;
            f3 = f1 + f2;
        }
	}
}

Output:

1 1 2 3 5 8 13 21 34 55

Coming soon


7. Binary Search


Coming soon

public class BinarySearch {
	int binarySearch(int arr[], int x) 
	{ 
		int l = 0, r = arr.length - 1; 
		while (l <= r) { 
			int m = l + (r - l) / 2; 

			// Check if x is present at mid 
			if (arr[m] == x) 
				return m; 

			// If x greater, ignore left half 
			if (arr[m] < x) 
				l = m + 1; 

			// If x is smaller, ignore right half 
			else
				r = m - 1; 
		} 

		// if we reach here, then element was not present 
		return -1; 
	} 

	public static void main(String args[]) 
	{ 
		BinarySearch bs = new BinarySearch(); 
		int arr[] = { 8, 9, 56, 89, 889,6777 }; 
		int n = arr.length; 
		int x = 889; 
		int r = bs.binarySearch(arr, x); 
		if (r == -1) 
			System.out.println("Element not present"); 
		else
			System.out.println("Element found at index : " +r); 
	} 
}

Output:

Element found at index : 4

Coming soon


8. Prime Number


Coming soon

public class PrimeNum {
  public static void main(String[] args) {

    int num = 31;
    boolean flag = false;
    for (int i = 2; i <= num / 2; ++i) {
      if (num % i == 0) {
        flag = true;
        break;
      }
    }

    if (!flag)
      System.out.println(num + " is a prime number.");
    else
      System.out.println(num + " is not a prime number.");
  }
}

Output:

31 is a prime number.

Coming soon


9. Decimal to Binary


Coming soon

public class DecimalToBinary {
  public static void main(String[] args) {

      int decimalNum=13,temp;
      String strConvert = "";
      while(decimalNum > 0)
      {
        temp = decimalNum % 2;
        strConvert = strConvert + "" + temp;
        decimalNum /=2;
      }
      System.out.println("Decimal to binary : " + strConvert);
      }
}

Output:

Decimal to binary :1011

Coming soon


10. GCD and LCM


Coming soon

public class GcdOfTwoNum {
  public static void main(String[] args) {
      	int n1 = 90, n2 = -150;
		n1 = ( n1 > 0) ? n1 : -n1;
        n2 = ( n2 > 0) ? n2 : -n2;

        while(n1 != n2)
        {
            if(n1 > n2)
                n1 -= n2;
            else
                n2 -= n1;
        }
        System.out.println("G.C.D of two numbers = " + n1);
        }
}

Output:

G.C.D of two numbers = 30

Coming soon