Saturday, 20 March 2021

Bucket Sort Program

 //write a program to sort the number to bucket sort

#include<stdio.h>

#include<conio.h>

void main()

{

int a[100],i,j=0,k,n,max=1,ten=1,low=0,temp,skp,t;

clrscr();

printf("enter no:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

printf("\nenter n:");

scanf("%d",&a[i]);

}

for(i=1;i<=n;i++)

{

while((a[i]/ten)!=0)

{

j++;

ten=ten*10;

}

if(j>max)

{

max=j;

}

j=0;

ten=1;

}

for(i=1;i<=max;i++)

{

low=0;

k=1;

while(low<10)

{

for(j=k;j<=n;j++)

{

if((a[j]/ten)%10==low)

{

temp=a[j];

for(skp=j;skp>k;skp--)

{

a[skp]=a[skp-1];

}

a[skp]=temp;

k++;

}

}

low++;

}

ten=ten*10;

printf("\nafter itretion%d:",i);

for(t=1;t<=n;t++)

{

printf("%d\t",a[t]);

}

}

printf("\nsorted data\n");

for(i=1;i<=n;i++)

{

printf("%d\t",a[i]);

}

getch();

}

Monday, 5 March 2018

Visual Studio IDE

Setup windows forms application in c#

Download the following pdf file for the steps to create setup files
https://drive.google.com/file/d/1DiSyZy-QwVM8Pygle1Yx-7slcgxh3r9h/view?usp=sharing

Collection in C#

Reference Link:
1. http://www.tutorialsteacher.com/csharp/csharp-collection
2. http://www.c-sharpcorner.com/UploadFile/736bf5/collection-in-C-Sharp/
3.https://www.tutorialspoint.com/csharp/csharp_collections.htm 
Non-generic Collections Usage
ArrayList ArrayList stores objects of any type like an array. However, there is no need to specify the size of the ArrayList like with an array as it grows automatically.
SortedList SortedList stores key and value pairs. It automatically arranges elements in ascending order of key by default. C# includes both, generic and non-generic SortedList collection.
Stack Stack stores the values in LIFO style (Last In First Out). It provides a Push() method to add a value and Pop() & Peek() methods to retrieve values. C# includes both, generic and non-generic Stack.
Queue Queue stores the values in FIFO style (First In First Out). It keeps the order in which the values were added. It provides an Enqueue() method to add values and a Dequeue() method to retrieve values from the collection. C# includes generic and non-generic Queue.
Hashtable Hashtable stores key and value pairs. It retrieves the values by comparing the hash value of the keys.
BitArray BitArray manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0).


For more details click on the link that is given in the table.
Also download the file for more information:
https://drive.google.com/file/d/1ZgkfZpeil3tXdccLpbFE2HjZmfgnjypK/view?usp=sharing




































COMPONENTS OF CONNECTED AND DISCONNECTED ARCHITECTURE IN C#

Reference Link: http://www.c-sharpcorner.com/UploadFile/8a67c0/connected-vs-disconnected-architecture-in-C-Sharp/
You can use two C# objects to achieve this, first one is DataSet and other one is DataReader.

DataSet

DataSet

It is a type of disconnected architecture. Disconnected architecture means, you don’t need to connect always when you want to get data from the database. You can get data from dataset; basically DataSet is a collection of datatables. We can store the database table, view data in the DataSet and can also store the xml value in dataset and get it if required.

To achieve this you need to use DataAdapter which work as a mediator between Database and DataSet.

Example


public DataSet GetEmployeeData()
{
    SqlConnection conString = new SqlConnection("myconnection");
    conString.Open();
    SqlCommand cmdQuery = new SqlCommand("Select * from Employee", conString);
    SqlDataAdapter sda = new SqlDataAdapter(cmdQuery);
    DataSet dsData = new DataSet();
    sda.Fill(dsData);
    return dsData;
}  
DataReader

It is a connected architecture, which means when you require  data from the database you need to connect with database and fetch the data from there. You can use if you need updated data from the database in a faster manner. DataReader is Read/Forward only that means we can only get the data using this but we cannot update or insert the data into the database. It fetches the record one by one.

Example
static void HasRows(SqlConnection connection)
{
    using (connection)
    {
        SqlCommand command = new SqlCommand("SELECT CategoryID, CategoryName FROM Categories;",connection);
        connection.Open();
        SqlDataReader reader = command.ExecuteReader();
        if (reader.HasRows)
        {
            while (reader.Read())
            {
                Console.WriteLine("{0}\t{1}", reader.GetInt32(0),reader.GetString(1));
            }
        }
        else
        {
            Console.WriteLine("No rows found.");
        }
        reader.Close(); 
    }

For more details download the following PDF file
https://drive.google.com/file/d/1kuDA7y7MmQcvE9W5vq6bdN-_CRsNVD5R/view?usp=sharing