Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Thursday, May 15, 2014

A brief history of the thoughts about CS/CSE in Bangladesh!

বাংলাদেশের মানুষের এক
অংশের ধারণা কম্পিউটার
সায়েন্সে ওয়ার্ড, পাওয়ারপয়েন্ট
এসব শেখানো হয়,
এবং এগুলো যেহেতু পাড়ার
দোকানদারও ভালো পারে তাই
কম্পিউটার সায়েন্স পড়ার
কোনো মানে নাই। আবার
কম্পিউটার
সম্পর্কে ভালো জানে, টুকটাক
প্রোগ্রামিংও
কিছুটা জানে এমন মানুষের
ধারণা এখানে শুধু এইচটিমিএল,
পিএইচপিতে এ ওয়েবসাইট
বানানো শেখায়,
যেগুলো কম্পিউটার সায়েন্স
না পড়লেও শেখা যায়,
ফ্রিল্যান্সারদের মধ্যে এই
ধারণাটা বেশি কাজ করে।
এখন আমরা তাহলে এক এক
করে দেখি কম্পিউটার
সায়েন্সে কি কি টপিক পড়তে হবে।
টপিকগুলো সম্পর্কে সংক্ষেপে আমরা জানবো।
এরপরে নিজেই সিদ্ধান্ত
নেয়া যাবে উপরের
ধারণা গুলো কতটা সত্যি।

ডেভেলপমেন্টের সময় গিট ব্যবহারের সহজ ওয়ার্ক-ফ্লো

আজকালকার দিনে ভার্সন কন্ট্রোল টুল বা ভিসিএস ব্যবহার করে না এরকম টিমের দেখা পাওয়া একটু মুশকিল। ভার্সন কন্ট্রোল টুল এত উপকারী যে দেখা যায় বেশীর ভাগ ডেভেলপার একা কাজ করলেও বা সিংগেল ম্যান প্রজেক্ট হলেও সোর্স কোড সফলভাবে ম্যানেজ করার জন্য কোন না কোন টুল ব্যবহার করে থাকে। বর্তমানে জনপ্রিয়তার দিক দিয়ে ভার্সন কন্ট্রোল টুল গুলোর মাঝে গিট (git), সাবভার্সন (svn), মারকুরিয়াল, বাজার ইত্যাদি বেশি প্রচলিত। কেউ কেউ মাইক্রোসফটের ভিজ্যুয়াল সোর্স সেফ ও ব্যবহার করে থাকে। আজকের এই আর্টিকেলে আমি ভার্সন কন্ট্রোল টুল কেন ব্যবহার করা লাগে বা সুবিধা কি সেগুলো নিয়ে আলোচনা না করে বরং একটা স্পেসিফিক বিষয় নিয়ে বলবো, আর সেটা হল ডেভেলপমেন্টের সময় গিট ব্যবহার করে কিভাবে একটা নির্দিষ্ট ওয়ার্কফ্লো ফলো করে আমাদের ডেভেলপমেন্ট সাইকেল আরও সহজ করতে পারি বা আরও প্রোডাক্টিভ ভাবে সোর্স কোড ম্যানেজ করতে পারি।

✅০. আমরা ধরে নেই আমরা একটা ছোট দল, যেখানে নদু_ডেভ, যদু_ডেভ এবং গেদু_ডেভ ডেভেলপার হিসেবে কাজ করছে। এই দলের লিড বা কোড মেইনটেইনার হিসেবে কাজ করছে হালুম_লিড।
✅১. প্রজেক্টে গিট ব্যবহার করা হচ্ছে শুরু থেকেই। গিটে develop এবং master নামে দুটো ব্রাঞ্চ আছে
✅২. নদু, গেদু এবং যদু প্রজেক্টের develop ব্রাঞ্চ নিয়ে কাজ করছে। তাদের যার যার টাস্ক তারা এই develop ব্রাঞ্চে কমিট (git commit) দিবে এবং পুশ করবে। এছাড়াও তাদের নিজেদের কোড অন্যদের সাথে হালনাগাদ রাখার জন্য তারা সবসময় develop ব্রাঞ্চ থেকে পুল (git pull) নিবে। পুশ (git push) দেয়ার সময়ে তারা খেয়াল রাখবে যেন ব্রোকেন বা ইন-কমপ্লিট কোন কোড পুশ না হয়ে যায়।
✅৩. এখন মনে করি হালুম_লিড প্রজেক্টের একটা ফিচার নিয়ে নদুকে কাজ করতে দিয়েছে, ফিচার টার নাম “সহজ_ফিচার”। একই সাথে গেদুকে দেয়া হয়েছে অপেক্ষাকৃত ঝামেলার “মাঝারী_ফিচার”। যদুও পেয়েছে “ঝামেলা_ফিচার” তার ভাগে।
✅৪. যেহেতু অপেক্ষাকৃত সহজ এবং ছোট কাজ, নদু সরাসরি develop ব্রাঞ্চেই কাজ করতে পারে। কাজ শেষে সে কমিট এবং পুশ করবে develop ব্রাঞ্চে।
✅৫. একটু সময় বেশী লাগবে এবং পরীক্ষা নিরিক্ষা বেশী করা লাগবে দেখে গেদু তার মেশিনে develop ব্রাঞ্চ থেকে নতুন একটা ব্রাঞ্চ করে নিবে – ধরে নেই তার নাম “মাঝারী_ব্রাঞ্চ”। যদুও একই ভাবে কাজ করার সময় সরাসরি develop ব্রাঞ্চে কাজ না করে develop ব্রাঞ্চ থেকে নিজের মেশিনে একটা নতুন ব্রাঞ্চ করে নিবে “ঝামেলা_ব্রাঞ্চ” নামে। এই দুটি ব্রাঞ্চে তারা কমিট দিবে কিন্তু তারা কেউ এই ব্রাঞ্চদুটো পুশ করবে না।
✅৬. গেদুর কাজ হয়ে গেলে সে develop ব্রাঞ্চের সাথে তার মাঝারী_ব্রাঞ্চ মার্জ (git merge) করে দিবে। এক্ষেত্রে মার্জ করার আগে সে ড্রাই রান করে দেখে নিতে পারে যে কোন কনফ্লিক্ট হতে পারে কিনা। মার্জ করার পরে কনফ্লিক্ট হলে সে কনফ্লিক্ট রিসলভ (conflict resolve) করে আবার develop ব্রাঞ্চ কমিট এবং পুশ দিবে।
✅৭. যদুও তার কাজ হয়ে গেলে সে তার ঝামেলা_ব্রাঞ্চ একই ভাবে ডেভেলপ ব্রাঞ্চের সাথে মার্জ করে দিবে।
✅৮. develop ব্রাঞ্চের সাথে সফল ভাবে মার্জ হয়ে গেলে যদু এবং গেদু তাদের লোকাল ব্রাঞ্চ দুটো ডিলেট করে দিবে, কারন সেগুলোর আর প্রয়োজন নেই
✅৯. হালুম_লিড এখন চেক করবে যে develop ব্রাঞ্চের সব কিছু ঠিক আছে কিনা। যদি ঠিক থাকে তাহলে সে develop ব্রাঞ্চ master ব্রাঞ্চের সাথে মার্জ করে দিবে। এই মাস্টার ব্রাঞ্চে মার্জ কখনোই নদু_ডেভ, গেদু_ডেভ বা যদু_ডেভ করবে না।
✅১০. প্রোডাকশন সার্ভারে ডেপ্লয় করার সময় এলে হালুম_লিড দেখবে যে master ব্রাঞ্চের সব কোড ঠিকমত টেস্ট (ইউনিট টেস্ট) পাশ করছে কিনা। যদি টেস্ট পাশের হার অ্যাক্সেপ্টেবল হয় তাহলে সে সার্ভারে কোড ডেপ্লয় করে দিবে

এই হল মোটামুটি গিট নিয়ে কাজের ওয়ার্ক-ফ্লো। ১০ নম্বর পয়েন্ট টা অবশ্য গিটের সাথে সম্পর্কিত না, তাও উল্লেখ করলাম আর কি
courtesy #hasin hayder

Saturday, April 5, 2014

Java Program to Implement crammers rule


import java.util.Scanner;

public class CramerBackEnd {
    public  float calcdeterminant(float temp2[][] ) {  // returns the value of the calculated determinant
        float diter1= temp2[0][0]*( (temp2[1][1]*temp2[2][2] )-(temp2[2][1]*temp2[1][2]) );
        float diter2= temp2[0][1]*( (temp2[1][0]*temp2[2][2] )-(temp2[2][0]*temp2[1][2]) );
        float diter3= temp2[0][2]*( (temp2[1][0]*temp2[2][1] )-(temp2[2][0]*temp2[1][1]) );
        float result = diter1-diter2+diter3;
        return result;
    }   
}
   
public class MainCramers {
    public static void main(String args[]){
       Scanner scan = new Scanner(System.in)  ;
       CramerBackEnd process = new CramerBackEnd();
      
        float matrix[][] =    new float[5][5];
        float temp1[][]=      new float [5][5];
        float temp2[][]=      new float [5][5];
      
        System.out.println("plz give the value of the 3x4 matrix:");
        for(int i =0;i<3;i++){ //  loop i begins
            for(int j=0;j<4;j++) { // loop j begins
              
        System.out.println(" the matrix"+(i+1)+ (j+1) );
              
        matrix[i][j]= scan.nextFloat();
                temp1[i][j]= matrix[i][j];
                temp2[i][j]= matrix[i][j];
              
             } //  loop j ends
        }// loop i  ends
       
       matrix[0][0]= matrix[0][3]; matrix[1][0]= matrix[1][3]; matrix[2][0]= matrix[2][3];  //
       temp1[0][1]= matrix[0][3]; temp1[1][1]= matrix[1][3]; temp1[2][1]= matrix[2][3];  //
       temp2[0][2]= matrix[0][3]; temp2[1][2]= matrix[1][3]; temp2[2][2]= matrix[2][3];  //
      
       float determinant = process.calcdeterminant(matrix);
      
        System.out.println("the determinant:"+determinant);
     
       System.out.printf("The value of X1:");
       float var1 = process.calcdeterminant(matrix)/determinant;
       System.out.printf("%.5f\n",var1);
      
       System.out.printf("The value of X1:");
       float var2 = process.calcdeterminant(temp1)/determinant;
       System.out.printf("%.5f\n",var2);
      
       System.out.printf("The value of X1:");
       float var3 = process.calcdeterminant(temp2)/determinant;
       System.out.printf("%.5f\n",var3);
      
    }
}

C Program to Implement crammers rule

#include <stdio.h>

int det3(int a[3][3]);

int main(void)
{
    int A[3][3];
    int B[3];

    printf("This program uses Cramer's Rule to solve a linear system.\
            Enter each of 3 linear equations as four integers separated by space.\
              For example, x - 2y + 3z = 4 should be entered as 1 -2 3 4");
    printf("\n\nEnter equation 1: ");
    scanf("%i %i %i %i", &A[0][0], &A[0][1], &A[0][2], &B[0]);
    printf("Enter equation 2: ");
    scanf("%i %i %i %i", &A[1][0], &A[1][1], &A[1][2], &B[1]);
    printf("Enter equation 3: ");
    scanf("%i %i %i %i", &A[2][0], &A[2][1], &A[2][2], &B[2]);

    /*Finding determinants*/

    int detx[3][3] = {{B[0],A[0][1],A[0][2]},{B[1],A[1][1],A[1][2]},
                          {B[2],A[2][1],A[2][2]}};
    int dety[3][3] = {{A[0][0],B[0],A[0][2]},{A[1][0],B[1],A[1][2]},
                          {A[2][0],B[2],A[2][2]}};
    int detz[3][3] = {{A[0][0],A[0][1],B[0]},{A[1][0],A[1][1],B[1]},
                          {A[2][0],A[2][1],B[2]}};

    /* Code that determines if the system has a unique solution */

      if(det3(A)!=0)
             printf("\nSystem has a unique solution ( %d, %d, %d)",
             det3(detx)/det3(A), det3(dety)/det3(A), det3(detz)/det3(A));
      else
             printf("\nSystem does not have a unique solution because determinant is 0");

    return 0;
}
int det3(int a[3][3])
{
    return (a[0][0]*a[1][1]*a[2][2])-(a[0][0]*a[1][2]*a[2][1]),
                +(a[0][1]*a[1][2]*a[2][0])-(a[0][1]*a[1][0]*a[2][2]),
                +(a[0][2]*a[1][0]*a[2][1])-(a[0][2]*a[1][1]*a[2][0]);
}

Java Program to Implement gauss elimination Method


import java.util.Scanner;


public class GaussElimination {
    public static void main(String args[]){
        Scanner in=new Scanner(System.in);
        System.out.println("press no of eqn:");
        int row = in.nextInt();
        int col = row+1;
        float mat[][]= new float [row][col];
        float x[] = new float [row];
       
        for (int i=0;i<row;i++){
            x[i]=0;
        }
       for(int i=0;i<row;i++){
           for (int j=0;j<col;j++){
               System.out.println("Press MAT"+(i+1)+(j+1));
               mat[i][j]= in.nextFloat();
           }
       }
       for(int i=0;i<row-1;i++){
           for(int j=i+1;j<row;j++){
               float a = mat[j][i];
               float b = mat[i][i];
               for(int k=0;k<col;k++){
                   mat[j][k]=mat[j][k]-mat[i][k]*(a/b);
               }
           }
       }
      
       System.out.println("forward elimination:");
       for(int i=0;i<row;i++){
           for(int j=0;j<col;j++){
               if(mat[i][j]==-0){
                   mat[i][j]=0;
               }
               System.out.printf("%.2f\t",mat[i][j]);
           }
           System.out.println();
       }
    System.out.println("backward substitution");
    for(int i=row-1;i>=0;i--){
        float temp =0;
        for (int j=0;j<col;j++){
            if(j<col-1){
                if(j<=i)
                    temp=mat[i][j]+temp;
                else
                    temp=mat[i][j]*x[j]+temp;
            }
            else
                temp=mat[i][j]/temp;  
        }
    x[i]=temp;
    }
    System.out.println("completed backward subt:");
  System.out.println("\n solutions") ;
  for(int i=0;i<row;i++){
      System.out.println("X"+(i+1)+"="+x[i]);
       
    }
 
    }
    }
   

C Program to Implement gauss elimination Method

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
  float mat[4][4],temp,temp1,x,y,z;
  int i,n,j;
  clrscr();
  printf("\nEnter size of matrix: ");
  scanf("%d",&n);
  for(i=0; i<n; i++)
  {
   printf("\n\nenter the value of %d eqvation",i+1);
   for(j=0; j<n; j++)
   {
    printf("\nenter the value of coeffcient %d: ",j+1);
    scanf("%f",&mat[i][j]);
   }
   printf("\nenter the value of constent: ");
   scanf("%f",&mat[i][j]);
  }

  printf("\n Your Matrix \n\n");
  for(i=0;i<n;i++)
  {
   for(j=0;j<n+1;j++)
   {
    printf(" %g ",mat[i][j]);
   }
   printf("\n\n");
  }

  temp=mat[1][0]/mat[0][0];
  temp1=mat[2][0]/mat[0][0];
  for(i=0,j=0;j<n+1;j++)
  {
   mat[i+1][j]=mat[i+1][j]-(mat[i][j]*temp);
   mat[i+2][j]=mat[i+2][j]-(mat[i][j]*temp1);
  }

  temp=mat[2][1]/mat[1][1];
  for(i=1,j=0;j<n+1;j++)
  {
   mat[i+1][j]=mat[i+1][j]-(mat[i][j]*temp);
  }


  for(i=0;i<n;i++)
  {
   for(j=0;j<n+1;j++)
   {
    printf(" %.3f ",mat[i][j]);
   }
   printf("\n\n");
  }

  z = mat[2][3]/mat[2][2];
  y = (mat[1][3] - mat[1][2]*z)/mat[1][1];
  x = (mat[0][3] - mat[0][2]*z - mat[0][1]*y)/mat[0][0];
  printf("\n\nx = %.3f",x);
  printf("\n\ny = %.3f",y);
  printf("\n\nz = %.3f",z);
  getch();
}


/*
______________________________________

         OUT PUT
______________________________________


enter the value of 1 eqvation
enter the value of coeffcient 1: 2

enter the value of coeffcient 2: 1

enter the value of coeffcient 3: 1

enter the value of constent: 10


enter the value of 2 eqvation
enter the value of coeffcient 1: 3

enter the value of coeffcient 2: 2

enter the value of coeffcient 3: 3

enter the value of constent: 18


enter the value of 3 eqvation
enter the value of coeffcient 1: 1

enter the value of coeffcient 2: 4

enter the value of coeffcient 3: 9

enter the value of constent: 16

  Your Matrix

 2  1  1  10

 3  2  3  18

 1  4  9  16

 2.000  1.000   1.000   10.000

 0.000  0.500   1.500   3.000

 0.000  0.000  -2.000  -10.000



x = 7.000

y = -9.000

z = 5.000


*/

Java Program to Implement bisection Method

import java.util.Scanner;

public class Bisection {

    public static double f(double x) {    // start of the method f
        double temp = Math.pow(x, 10) - 1;
        return temp;
    }// end of the method f

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        double x = 0;

        System.out.println("enter X (lower):");
        double a = input.nextDouble();

        System.out.println("enter X (upper):");
        double b = input.nextDouble();

        System.out.println("enter max iteration number:");
        int n = input.nextInt();
        int i;
        for (i = 1; i <= n; i++) { // for loop starts
            double temp = x;
            float error;
            x = (a + b) / 2;
            error = Math.abs((float) (((x - temp) / x) * 100));
            System.out.println("Iteration:" + i + "\ta=" + a + "\tb=" + b + "\tRoot:" + x + "\terror:" + error + "%");

            if (f(x) * f(a) < 0) {
                b = x;
            }

            if (f(x) * f(a) > 0) {
                a = x;
            }

            if (f(x) * f(a) == 0) {
                System.out.println("the root equals: " + x);
                break;
            }
           
        }// ends for loop here

        if (i > n)
         {
            System.out.println("max iteration exceeded:");

         }
    }
}

C Program to Implement bisection Method



#include<stdio.h>
#include <math.h>
#include<conio.h>
#define ESP 0.001
#define F(x) (x)*(x)*(x) + (x)*(x) + (x) + 7
void main()
{
  int i = 1;
  float x0,x1,x2;
  double f1,f2,f0,t;
  clrscr();
  printf("\nEnter the value of x0: ");
  scanf("%f",&x0);

  printf("\nEnter the value of x1: ");
  scanf("%f",&x1);
  printf("\n__________________________________________________________________\n");
  printf("\niteration\t x0\t       x1\t x2\t   f0\t   f1\t   f2");
  printf("\n___________________________________________________________________\n");
  do
  {
  x2=(x0+x1)/2;
  f0=F(x0);
  f1=F(x1);
  f2=F(x2);
  printf("\n%d %f %f %f %lf %lf %lf", i, x0,x1,x2,f0,f1,f2);
  if(f0*f2<0)
   {
    x1=x2;
   }
   else
   {
    x0=x2;
   }
   i++;
  }while(fabs(f2)>ESP);
printf("\n__________________________________________________________\n");
printf("\n\nApp.root = %f",x2);
getch();
}

/*
 OUT PUT
---------


Enter the value of x0: -2

Enter the value of x0: -1

Enter the value of x1: -2

__________________________________________________________

    x0         x1        x2        f0       f1      f2
__________________________________________________________

-1.000000 -2.000000 -1.500000 -5.000000 2.000000 -1.750000
-1.500000 -2.000000 -1.750000 -1.750000 2.000000  0.062500
-1.500000 -1.750000 -1.625000 -1.750000 0.062500 -0.859375
-1.625000 -1.750000 -1.687500 -0.859375 0.062500 -0.402344
-1.687500 -1.750000 -1.718750 -0.402344 0.062500 -0.170898
-1.718750 -1.750000 -1.734375 -0.170898 0.062500 -0.054443
-1.734375 -1.750000 -1.742188 -0.054443 0.062500  0.003967
-1.734375 -1.742188 -1.738281 -0.054443 0.003967 -0.025253
-1.738281 -1.742188 -1.740234 -0.025253 0.003967 -0.010647
-1.740234 -1.742188 -1.741211 -0.010647 0.003967 -0.003341
-1.741211 -1.742188 -1.741699 -0.003341 0.003967  0.000313
__________________________________________________________


App.root = -1.741699


*/

Java Program to Implement Iterative Method

import java.util.Scanner;

public class IterativeProcess {

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        float a, x, b, c, sum;

        float result[] = new float[100];

        System.out.println("for the quadratic equation:ax^2+bx+c");
        System.out.println("enter the value of a:?");
        a = input.nextFloat();

        System.out.println("enter the value of b:?");
        b = input.nextFloat();

        System.out.println("enter the value of c:?");
        c = input.nextFloat();

        System.out.println("enter the starting value of x:?");
        x = input.nextFloat();
        x = (-c - a * x * x) / b;
       
        result[0]=x;
        System.out.printf("The equation is: %.2fx^2 + (%.2f)x + %f = 0 \n", a, b, c);

        //   for(int i=x;i<=10;i++){ // loop starts here

        for (int i =0;; i++) { // loop starts here
         
           // System.out.printf("The value at SN:=%d is:%f \n", i+1, result[i]); 
           
            sum =  (-c - a * x * x) / b;
            result[i+1] = sum;

            if (result[i+1] == x) {
                break;
            }
             System.out.printf("The value at SN:=%d is:%f \n", i+1, result[i]); 
            x = sum;
           


        }// loop ends here
        if ((result[1] - result[2]) >(result[2] - result[3])) {
            System.out.println("\n........................... The function is Converging...........................");
        } else {
            System.out.println("\n ........................ ..The function is Diverging..........................");
        }
    }
}

Java Program to Implement N-R (NewtonRaphson) METHOD

import java.util.Scanner;
public class NewtonRaphson2 {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
       
        System.out.println("guess the initial value:");
        float x= input.nextFloat();
        float err=0;
        System.out.println("enter the no: of iteration:");  
        int time= input.nextInt();
        System.out.println("\n Iteration \t\t X \t\t\t Error(%)");
       
        for(int i =1;i<=time;i++)
        {
            float temp =x;
            x= x-(((float)Math.exp(-x))-x)/((-(float)Math.exp(-x))-1);
            err =Math.abs(((x-temp)/x)*100);
                   
            if(err<0.0001)
            {
                System.out.println(i-1 + "\t\t" + x + "\t\t" +err+ "%" /*+ "\n This is done....."*/);
                break;
            }
           
            else if (i<=2)
                System.out.println(i-1 + "\t\t" + x + "\t\t" + err +"%");
            else
                System.out.println(i + "\t\t" + x + "\t\t" + err+ "%");
       
        if(err<0.0001)
        {
            System.out.println(i + "\t\t" + x + "\t\t" + err +"%");
        }
        else
             System.out.println(i-1 + "\t\t" + x + "\t\t" + err +"%");
       
    }
}
}

C Program to Implement N-R (NewtonRaphson) METHOD

#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int user_power,i=0,cnt=0,flag=0;
int coef[10]={0};
float x1=0,x2=0,t=0;
float fx1=0,fdx1=0;

void main()
{

    clrscr();

    printf("\n\n\t\t\t PROGRAM FOR NEWTON RAPHSON GENERAL");

    printf("\n\n\n\tENTER THE TOTAL NO. OF POWER:::: ");
    scanf("%d",&user_power);

    for(i=0;i<=user_power;i++)
    {
        printf("\n\t x^%d::",i);
        scanf("%d",&coef[i]);
    }

    printf("\n");

    printf("\n\t THE POLYNOMIAL IS ::: ");
    for(i=user_power;i>=0;i--)//printing coeff.
    {
        printf(" %dx^%d",coef[i],i);
    }

    printf("\n\tINTIAL X1---->");
    scanf("%f",&x1);

    printf("\n ******************************************************");
    printf("\n ITERATION    X1    FX1    F'X1  ");
    printf("\n **********************************************************");

    do
    {
            cnt++;
            fx1=fdx1=0;
            for(i=user_power;i>=1;i--)
            {
                fx1+=coef[i] * (pow(x1,i)) ;
            }
            fx1+=coef[0];
            for(i=user_power;i>=0;i--)
            {
                fdx1+=coef[i]* (i*pow(x1,(i-1)));
            }
            t=x2;
            x2=(x1-(fx1/fdx1));

            x1=x2;

            printf("\n %d         %.3f  %.3f  %.3f ",cnt,x2,fx1,fdx1);

    }while((fabs(t - x1))>=0.0001);
    printf("\n\t THE ROOT OF EQUATION IS %f",x2);
    getch();
}





















/*
This program have written for the course named Numerical Method
        Author : Fazle Rabbi
        My social site's link
______________________________________________________________
https://www.facebook.com/FazleRabbi.CSE
https://twitter.com/Fazle_Rabbi_CSE
http://lnkd.in/bzuUfbM
https://plus.google.com/u/0/106347450745435143158/posts
http://www.youtube.com/channel/UC4Ni4G1TIydmdXNFxeqskvQ
http://www.flickr.com/photos/108286097@N08/
https://vimeo.com/user22555382
http://www.pinterest.com/fazlerabbicse/
https://foursquare.com/user/71317652
            Website:
______________________________________________________________
www.fazlerabbicse.blogspot.com
www.awesome-fazle-rabbi.tumblr.com

            Email me
______________________________________________________________
fazlerabbicse@gmail.com
fazlerabbi@ojooo.com
*/


Sunday, January 26, 2014

নিজের হাতেই তৈরি করে নিন "সি ক্লিনার" (সিস্টেম ক্লিনার)

 
আজ আপনাদের শিখাবো কিভাব নিজের হাতে আপনি নিজের কম্পিউটার সিস্টেমকে জঞ্জালমুক্ত রাখার জন্য প্রোগ্রামিং করতে পারেন। এজন্য আপনার তেমন কোন দক্ষতার প্রয়োজন নেয়। আমরা আমাদের সিস্টেমকে পরিষ্কার ও গতিশীল রাখতে কত সফটওয়্যারই না ব্যবহার করি। কেমন হয় যদি এই কাজগুলো আমাদের হাতের তৈরি কোন সফটওয়্যার করে ফেলতে পারে।
এজন্য নিচের লেখাগুলো হুবহু কপি করে একটি নোটপ্যাডে পেস্ট করুন।

@echo off
del /s /f /q %windir%\temp\*.*
rd /s /q %windir%\temp
md %windir%\temp
del /s /f /q %windir%\Prefetch\*.*
rd /s /q %windir%\Prefetch
md %windir%\Prefetch
del /s /f /q %windir%\system32\dllcache\*.*
rd /s /q %windir%\system32\dllcache
md %windir%\system32\dllcache
del /s /f /q “%SysteDrive%\Temp”\*.*
rd /s /q “%SysteDrive%\Temp”
md “%SysteDrive%\Temp”
del /s /f /q %temp%\*.*
rd /s /q %temp%
md %temp%
del /s /f /q “%USERPROFILE%\Local Settings\History”\*.*
rd /s /q “%USERPROFILE%\Local Settings\History”
md “%USERPROFILE%\Local Settings\History”
del /s /f /q “%USERPROFILE%\Local Settings\Temporary Internet Files”\*.*
rd /s /q “%USERPROFILE%\Local Settings\Temporary Internet Files”
md “%USERPROFILE%\Local Settings\Temporary Internet Files”
del /s /f /q “%USERPROFILE%\Local Settings\Temp”\*.*
rd /s /q “%USERPROFILE%\Local Settings\Temp”
md “%USERPROFILE%\Local Settings\Temp”
del /s /f /q “%USERPROFILE%\Recent”\*.*
rd /s /q “%USERPROFILE%\Recent”
md “%USERPROFILE%\Recent”
del /s /f /q “%USERPROFILE%\Cookies”\*.*
rd /s /q “%USERPROFILE%\Cookies”
md “%USERPROFILE%\Cookies”


এবার File মেনুর Save as কমান্ডে ক্লিক করে ফাইলটির নাম দিন CCleaner.bat নামে। আর লোকেশন ডেক্সটপে দিয়ে দিন। এবার ডেস্কটপে গিয়ে দেখুন একটি ফাইল তৈরি হয়েছে প্রদত্ত নামে। এখন থেকে ঐ ফাইলটিতে ডাবল ক্লিক করলেই আপনার কম্পিউটারের সমস্ত জঞ্জাল পরিষ্কার হয়ে যাবে।
Thanks
Fazle Rabbi

Sunday, December 22, 2013

Connect Java with Oracle 10g Tutorial

For Windows users only

Pre-Requisites:
  1. jdk1.6.0_11
  2. Oracle 10g
  3. ojdbc14.jar
If you want to access oracle10g via JDBC you need to set CLASSPATH environment variable to find the ojdbc14.jar file provided by Oracle. The file is located in:  C:\oracle\product\10.1.0\Db_1\jdbc\lib\ojdbc14.jar           beneath you Oracle home directory, or it’s available for download from http://technet.oracle.com or http://www.findjar.com/
If you are using older version of JDK(1.2 or below). You need to set CLASSPATH for classes12.zip
C:\oracle\product\10.1.0\Db_1\jdbc\lib\classes12.zip
Step:1
Setting CLASSPATH
1. Right click the My Computer icon. In that click properties
2. You will see a window System Properties. In that window click Advanced
3. You will see a button Environment Variables. Click that button.
4. In the popup window you will see User variables for XXXXXX (your name) and System variable. Select the New button which is below the User variables for XXXXX.
5.  You will see the window New User Variable. In Variable name type CLASSPATH and in Variable value type .;C:\oracle\product\10.1.0\Db_1\jdbc\lib\ojdbc14.jar
The first entry must be a period, which denotes the current directory. The second entry must be the directory for the ojdbc14.jar or classess12.zip (jdk 1.2 or below).
If CLASSPATH is not set correctly, you will get a NoClassDefFoundError error when you run a compile class.
NOTE
Be sure to use a version of the JDK that is compatible with the Oracle release you are using.  If you use a new release of the JDK with an older release of Oracle’s drivers, you may encounter “access violation” errors when executing your programs.
Step 2
The PATH environment variable should already be set for JDK Step 3
JDK is already provided by Oracle itself(You can even use your own JDK). If you install Oracle10g It comes automatically. It lies in
C:\oracle\product\10.1.0\Db_1\jdk(I have installed oracle in C: in your case it might be D: or E: ….)
Setting PATH
1. Right click the My Computer icon. In that click properties
2. You will see a window System Properties. In that window click Advanced
3. You will see a button Environment Variables. Click that button.
4. In the popup window you will see User variables for XXXXXX (your name) and System variable. Select the New button which is below the User variables for XXXXX.
5.  You will see the window New User Variable. In Variable name type PATH and in Variable value type
C:\oracle\product\10.1.0\Db_1\jdk\bin;
Click ok. You have finished setting PATH and CLASSPATH.


Testing your Connection
Oracle provides a sample program called JdbcCheckup.java that you can use to verify your JDBC configuration. This file may be in a zip file (demo.zip on the C:\oracle\product\10.1.0\Db_1\jdbc\demo.zip.  After unzipping you will get C:\oracle\product\10.1.0\Db_1\jdbc\demo\samples\generic\. You will need to extract it before running the program. Go to the directory where the sample file is, then compile and execute the JdbcCheckup.iava class:
javac  JdbcCheckup.java
Java JdbcCheckup

NOTE
Java commands are case sensitive. When you execute jdbcCheckup, you are prompted for usename, password, and connect string for a database. That connection Information will be used to attempt a connection; if successful, that attempt will return the following output:

Connecting to the database...Connecting…
 connected.
Hello World.
Your JDBC Installation is correct.
If you don't receive feedback telling you that your Installation is correct, you need to check your configuration. Common problems include incorrectly set environment variables (PATH and CLASSPATH) and mismatched versions of database connection drivers. It you change the environment variable values, you need to shut down and restart the command windows for the changes to take effect.
If you are not able to find demo.zip then try the below programs.

Sample programs

Sample program: 1
ConnectOracle.java

  1. /** 
  2.  * ConnectOracle.java 
  3.  */  
  4. package com.fazle.connectoracle;  
  5.   
  6. import java.sql.Connection;  
  7. import java.sql.DriverManager;  
  8. import java.sql.ResultSet;  
  9. import java.sql.Statement;  
  10.   
  11. /** 
  12.  * @author www.fazlerabbicse.blogspot.com 
  13.  *  
  14.  */  
  15. public class ConnectOracle {  
  16.   
  17.     public static void main(String[] args) {  
  18.   
  19.         try {  
  20.             DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());  
  21.             System.out.println("Connecting to the database...");  
  22.             Connection connection = DriverManager.getConnection(  
  23.                     "jdbc:oracle:thin:@localhost:1521:orcl""scott""tiger");  
  24.             Statement statement = connection.createStatement();  
  25.             ResultSet resultset = statement.executeQuery("select 'Connected' from dual");  
  26.             resultset.next();  
  27.             String s = resultset.getString(1);  
  28.             System.out.println(s);  
  29.             statement.close();  
  30.             connection.close();  
  31.         } catch (Exception e) {  
  32.             System.out.println("The exception raised is:" + e);  
  33.         }  
  34.     }  
  35.   
  36. }  
connection=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
In the above line, username is “scott” and password is “tiger”.
Thin is the JDBC driver
1521 is the default port number which the connection is to be established and orcl is the database name.
Sample program: 2

ConnectOracle.java

  1. /** 
  2.  * ConnectOracle.java 
  3.  */  
  4. package com.fazle.connectoracle;  
  5.   
  6. import java.sql.Connection;  
  7. import java.sql.DriverManager;  
  8. import java.sql.ResultSet;  
  9. import java.sql.Statement;  
  10.   
  11. /** 
  12.  * @author www.fazlerabbicse.blogspot.com
  13.  *  
  14.  */  
  15. public class ConnectOracle {  
  16.     public static void main(String[] args) {  
  17.         try {  
  18.             DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());  
  19.             Connection connection = DriverManager.getConnection(  
  20.                     "jdbc:oracle:thin:@localhost:1521:orcl""scott""t");  
  21.   
  22.             Statement statement = connection.createStatement();  
  23.             ResultSet resultSet = statement  
  24.                     .executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");  
  25.             while (resultSet.next()) {  
  26.                 System.out.println("EMPLOYEE NAME:"  
  27.                         + resultSet.getString("EMPNAME"));  
  28.             }  
  29.         } catch (Exception e) {  
  30.             e.printStackTrace();  
  31.         }  
  32.     }