Posts

Showing posts from July, 2016

5th sem ADA programm to implement sorting algorithms

Bubble sort in c #include<stdio.h> void bubble(int n,int arr[]); void main() {     int n;     printf("enter the size of array:");     scanf("%d",&n);     int arr[n];     int i,j,k;     printf("enter the array elemets:\n");     for(i=0;i<n;i++)     {         scanf("%d",&arr[i]);     }     bubble(n,arr);      printf("\nyour sorted array is :\n");     for(i=0;i<n;i++)     {         printf("%d\n",arr[i]);     } } void bubble(int n, int arr[n]) {     int i,j,swap;     for(i=0;i<n;i++)     {         for(j=0;j<n-i-1;j++)         {             if(arr[j]>arr[j+1])             {   ...

5th sem ADA programm to implement sorting algorithms

 Insertion sort in c #include<stdio.h> void insertion(int n,int arr[]); void main() {     int n,i;     printf("enter the size of array:");     scanf("%d",&n);     int arr[n];     printf("enter the array elements:\n");     for(i=0;i<n;i++)     {         scanf("%d",&arr[i]);     }     insertion(n,arr);     printf("\nyour sorted array is:\n");     for(i=0;i<n;i++)     {         printf("%d\n",arr[i]);     } } void insertion(int n,int arr[n]) {     int i,j,swap;     for(i=1;i<n;i++)     {         j=i;         while(j>0 && arr[j] < arr[j-1])         {             swap=arr[j];       ...

4th sem OOPC Write the following programs using INHERITANCE in CPP language.

1.        To enter and display the student data using single inheritance technique. #include<iostream> #include<conio.h> using namespace std; class student{ public:     int roll_no;     char name[20];     void get(){         cout<<"\nEnter Student name: ";         cin>>name;         cout<<"Enter Student Roll No: ";         cin>>roll_no;     } }; class subject:public student{ public:     char sub1[10],sub2[10],sub3[10];         void getsub(){             cout<<"Enter first subject: ";             cin>>sub1;             cout<<"Enter Second subject: ";             cin>>sub2;         ...

4th sem OOPC Write the following programs using OPERATOR OVERLOADING in CPP language.

1.        Write a program to enter two integers, two float number, two double numbers and find and display the greater of them using function overloading technique. #include<iostream> #include<conio.h> using namespace std; class over{     public:     int get(int,int);     float get(float,float);     double get(double,double); }; int over::get(int a,int b){         if(a>b){             return a;         }else{             return b;         } } float over::get(float a,float b){         if(a>b){             return a;         }else{             return b;         } } double over::get(double a,double b){     if(a>b){   ...

4th sem OOPC Write the following programs using CONSTRUCTOR & DESTRUCTOR in CPP language.

1.        To enter two operands using constructor and perform arithmetic operations (+,-,*, /) on them and display the results. #include<iostream> #include<conio.h> using namespace std; class operation {     public:     int a,b;     operation(int x,int y)     {         a=x;         b=y;         cout<< a<< "+" << b <<"="<< a+b<<"\n";         cout<<a << "-"<<b<<"="<<a-b<<"\n";         cout<<a<<"*"<<b<<"="<<a*b<<"\n";         cout<<a<<"/"<<b<<"="<<a/b<<"\n";     } }; int main() {     int m,n;     cout <<"enter the values of oprands "<<endl;     cin>>m>>n; ...