Search

31 January, 2016

Connection Class in c# windows form

//Method one

using System.Data.SqlClient;
 
class myConnection
    {
        public static SqlConnection GetConnection()
        {
            string str = "Data Source=MANOZ\\SQLEXPRESS;Initial Catalog=softworksbd;Integrated Security=True;";
 
            SqlConnection con = new SqlConnection(str);
            con.Open();
            return con;
        }
    }

30 January, 2016

Flow chart and code to find the largest number among three integer




#include <iostream>
using namespace std;

int main() {
    
    float n1, n2, n3;
    cout << "Enter three numbers: ";
    cin >> n1 >> n2 >> n3;
    if (n1 >= n2) {
        if (n1 >= n3) {
            cout << "Largest number: " << n1;
        }
        else {
            cout << "Largest number: " << n3;
        }
    }
    
    else {
        if (n2 >= n3) {
            cout << "Largest number: " << n2;
        }
        else {
            cout << "Largest number: " << n3;
        }
    }

    return 0;
}

29 January, 2016

Why RAM is Faster than Hard Disk

Hard Drive requires the sequential translation of information from an electro-mechanical
medium to a logical medium

RAM requires a sequential read from one logical medium to another logical medium to another.


Performance of hard disk is specified by the time required to move the heads to a track or cylinder (average access time) plus the time it takes for the desired sector to move under the head (average latency, which is a function of the physical rotational speed in revolutions per minute), and finally the speed at which the data is transmitted (data rate). In RAM the time required to read and write data items varies depending on their physical locations on the recording medium, due to mechanical limitations such as media rotation speeds and arm movement delays.

Every time you open a program, it gets loaded from the hard drive into the RAM. This is because reading data from the RAM is much faster than reading data from the hard drive. Running programs from the RAM of the computer allows them to function without any lag time. The more RAM your computer has, the more data can be loaded from the hard drive into the RAM, which can effectively speed up your computer. In fact, adding RAM can be more beneficial to your computer’s performance than upgrading the CPU. 

27 January, 2016

Generation of prime number in c

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

int main()
{
 int num, n, div, p;
 printf("Enter any number: ");

 scanf("%d", &num);

 for(n = 2; n <= num; n++)
 {
  for(div = 2; div < n; div++)
  {
   if(n % div == 0)
   {
     p = 0;
     break;
   }
   p = 1;
  }
  if(p)
    printf("%d ",n);
 }
 return 0;
}

Generation of prime number in c

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

int main()
{
 int num, n, div, p;
 printf("Enter any number: ");

 scanf("%d", &num);

 for(n = 2; n <= num; n++)
 {
  for(div = 2; div < n; div++)
  {
   if(n % div == 0)
   {
     p = 0;
     break;
   }
   p = 1;
  }
  if(p)
    printf("%d ",n);
 }
 return 0;
}

Generation of prime number in c

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

int main()
{
 int num, n, div, p;
 printf("Enter any number: ");

 scanf("%d", &num);

 for(n = 2; n <= num; n++)
 {
  for(div = 2; div < n; div++)
  {
   if(n % div == 0)
   {
     p = 0;
     break;
   }
   p = 1;
  }
  if(p)
    printf("%d ",n);
 }
 return 0;
}

Generation of Prime Number in c++ according to sieve algorithm


/*
Name: Manoz Kumar Biswas
E-mail: manozcsejust@gmail.com
Start Date: 08-03-2015
Date Update:
Purpose: TO generate a long list of prime number by dynamic programming approach
Input: a list of integer numbers
Output: a list of prime numbers among the integers

*/

#include <iostream>
#include <cmath>

using namespace std;

#define SIZE 121

long int primeList[SIZE];

int main()
{
    //cout << sizeof primeList;
    for(long int i = 2; i < SIZE; i++)
    {
        primeList[i] = 1; //at first we assume all is prime and all the position is marked by 1
    }

    for(long int i = 2; i <= sqrt(SIZE); i++)
    {
        if(primeList[i] == 1)
        {
            for(long int j = i + i; j < SIZE; j = j + i)
            {
                if(primeList[j] != 0){
                      primeList[j] = 0; //all the multiples of i are set to 0 to indicate not prime
                }
            }
        }
    }

    cout << "The list of prime numbers till 121 is" << endl;

    for(long int i = 2; i <= SIZE; i++)
    {

        if(primeList[i] == 1)
        {
            cout << i << " "; //shows only the position that are prime indicated by 1
        }
    }
    return 0;
}

Factorial in c++

#include <iostream>
using namespace std;

int main() {
    int i, n, factorial = 1;

    cout<<"Enter a positive integer: ";
    cin>>n;

    for (i = 1; i <= n; ++i) {
        factorial *= i;   // factorial = factorial * i;
    }

    cout<< "Factorial of "<<n<<" = "<<factorial;
    return 0;
}
 //Using recursion
#include<iostream>
#include<conio.h>

using namespace std;

//Function
long factorial(int);

int main()
{

     // Variable Declaration
     int counter, n;

     // Get Input Value
     cout<<"Enter the Number :";
     cin>>n;

     // Factorial Function Call
     cout<<n<<" Factorial Value Is "<<factorial(n);

     // Wait For Output Screen
     getch();
     return 0;
 }

// Factorial recursion Function
long factorial(int n)
{
  if (n == 0)
    return 1;
  else
    return(n * factorial(n-1));
}
 

Fibonacci series in c++

#include<iostream>
using namespace std;

int main(){

 int n, first = 0, second = 1, third;

 cout<< "enter the number of terms " << endl;
 cin >> n;

 cout << "first "<< n << " fibonaccy series"<< endl;

 for(int i = 1; i <= n ; i++){
    if(i <= 1){
        third = i;
    }
    else{
      third = first + second;
      first = second;
      second = third;

    }
cout << third << " ";
 }

return 0;
}


First 6 fibonacci series are 

1 1 2 3 5 8

25 January, 2016

Friend functions

In principle, private and protected members of a class cannot be accessed from outside the same class in which they are declared. However, this rule does not apply to "friends".

Friends are functions or classes declared with the friend keyword.

A non-member function can access the private and protected members of a class if it is declared a friend of that class. That is done by including a declaration of this external function within the class, and preceding it with the keyword friend:


// friend functions
#include <iostream>
using namespace std;

class Rectangle {
    int width, height;
  public:
    Rectangle() {}
    Rectangle (int x, int y) : width(x), height(y) {}
    int area() {return width * height;}
    friend Rectangle duplicate (const Rectangle&);
};

Rectangle duplicate (const Rectangle& param)
{
  Rectangle res;
  res.width = param.width*2;
  res.height = param.height*2;
  return res;
}

int main () {
  Rectangle foo;
  Rectangle bar (2,3);
  foo = duplicate (bar);
  cout << foo.area() << '\n';
  return 0;
}



The duplicate function is a friend of class Rectangle. Therefore,
 function duplicate is able to access the members width and height 
(which are private) of different objects of type Rectangle. 
Notice though that neither in the declaration of duplicate nor 
in its later use in main, function duplicate is considered a member 
of class Rectangle. It isn't! It simply has access to its private 
and protected members without being a member.
}

copy constructor

What is a copy constructor?
A copy constructor is a member function which initializes an object using another object of the same class. A copy constructor has the following general function prototype:
 ClassName (const ClassName &old_obj); 
Following is a simple example of copy constructor.

#include<iostream>
using namespace std;
class Point
{
private:
    int x, y;
public:
    Point(int x1, int y1) { x = x1; y = y1; }
    // Copy constructor
    Point(const Point &p2) {x = p2.x; y = p2.y; }
    int getX()            {  return x; }
    int getY()            {  return y; }
};
int main()
{
    Point p1(10, 15); // Normal constructor is called here
    Point p2 = p1; // Copy constructor is called here
    // Let us access values assigned by constructors
    cout << "p1.x = " << p1.getX() << ", p1.y = " << p1.getY();
    cout << "\np2.x = " << p2.getX() << ", p2.y = " << p2.getY();
    return 0;
Output:
p1.x = 10, p1.y = 15
p2.x = 10, p2.y = 15 

14 January, 2016

Thesis on Data visualization for Big data

https://www.cit.tu-berlin.de/menue/theses/available_theses/mt_big_data_visualization_topic_areamultiple_topics/

http://www.sas.com/en_us/insights/big-data/data-visualization.html

https://flowingdata.com/2008/05/23/5-data-visualization-dissertations-worth-a-look/

A New Way to VIsualize Global Health Data

https://www.youtube.com/watch?v=mususV-jMFk

Visual clues that a human brain processes is 250 ml seconds
Components of effective visualization:

4 important ingredients:

  • Visual ques/ visual encodings
  • Coordinate systems
  • Scale and data types
  • Context

Intro to Data Science Udacity

https://www.youtube.com/watch?
v=t4J6uKJ6qcw&list=PLAwxTw4SYaPk41og7PER4HBpGciPw6n3x&index=132