Posts

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; ...

4th sem oopc programs usinng function in cpp

Ø   Write the following programs using FUNCTION in CPP language. 1.        Write a program to find sum of three numbers using functions. 1.        Write a program to find sum of three numbers using functions. #include<iostream.h> #include<conio.h> int sum(int a,int b,int c){     return(a+b+c); } int main(){     int x,y,z;     clrscr();     cout<<"Enter three value:"<<endl;     cin>>x>>y>>z;     cout<<"Sum is "<<sum(x,y,z);     getch();     return 0; } 2.      Write a function big to find largest of two numbers and use this function in the main program to find largest of three numbers.  #include<iostream.h> #include<conio.h> int max(int,int); int max(int ,int ,int); int main(){     int a,b,c;   ...

4th sem oopc programs in CPP (C++)

Ø   Write the following programs in CPP (C++) language. 1.        To find highest of three numbers using if loop. #include<iostream.h> int main(){ int a,b,c; cout<<"Enter three Value of A B and C"<<endl; cin>>a>>b>>c; if(a>b){ cout<<"A is max"<<endl; }else if(b>c){ cout<<"B is max"<<endl; }else{ cout<<"C is max"<<endl; } return 0; } 2.        Write a program to convert degree Fahrenheit to Celsius. #include<iostream.h> #include<conio.h> void main(){    float f,c;    clrscr();    cout<<"Enter fahrenhit temp: \n";    cin>>f;    c=(f-32)*5/9;    cout<<"Farenhit temp \n"<<f;    cout<<"Eguivalent of celcius \n"<<c;    getch();    return 0; }   3.    ...