Tuesday 20 December 2011

Program to find average waiting and turn over time after sorting array


#include<iostream>
using namespace std;
class avg
{
 int a[10];
float w,tt,s,t,n;
public:
void read();
void display();
void awt();
void att();
void sort();
};
void avg::read()
{
        cout<<"enter no of members at theatre counter \n";
        cin>>n;
        cout<<"enter number of tickets want to purchase \n";
        for(int i=0;i<n;i++)
        {
        cout<<"a["<<i<<"]=";
        cin>>a[i];
        }
}
void avg::sort()
{
int x;
cout<<"before sorting\n";
        for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i]<<"\t";
        cout<<"after sorting\n";
        for(int j=0;j<n-1;j++)
        {
        for(int i=0;i<n-j-1;i++)
        {
                if(a[i]>a[i+1])
                {
                x=a[i];
                a[i]=a[i+1];
                a[i+1]=x;
                }
        }
}
for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i];
}
void avg::awt()
{       s=0;t=0;
        for(int i=0;i<n-1;i++)
        {
                s=s+a[i];
                t=t+s;
        }
cout<<"sum of awt is="<<t<<"\n";
        w=t/n;
}
void avg::att()
{
        t=0;s=0;
        for(int i=0;i<n;i++)
        {
                t=t+a[i];
                s=s+t;
        }
cout<<"sum of att is="<<s<<"\n";

        tt=s/n;
}
void avg::display()
{
        cout<<"no of tickets each person will purchase \n";
        for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i];
cout<<"average waiting time is"<<w<<"\n";
        cout<<"average turn over time is"<<tt<<"\n";
}
int main()
{
        avg ob;
        ob.read();
        ob.sort();
        ob.awt();
        ob.att();
        ob.display();
return 0;
}

Program to find average waiting and turn over time


#include<iostream>
using namespace std;
class avg
{
 int a[10],s,t,n,w,tt;
public:
void read();
void display();
void awt();
void att();
};
void avg::read()
{
        cout<<"enter no of members at theatre counter \n";
        cin>>n;
        cout<<"enter number of tickets want to purchase \n";
        for(int i=0;i<n;i++)
        {
        cout<<"a["<<i<<"]=";
        cin>>a[i];
        }
}
void avg::awt()
{       s=0;t=0;
        for(int i=0;i<n-1;i++)
        {
                s=s+a[i];
                t=t+s;
        }
cout<<"sum of awt is="<<t<<"\n";
        w=t/n;
}
void avg::att()
{
        t=0;s=0;
        for(int i=0;i<n;i++)
        {
                t=t+a[i];
                s=s+t;
        }
cout<<"sum of att is="<<s<<"\n";

        tt=s/n;
}
void avg::display()
{
        cout<<"no of tickets each person will purchase \n";
        for(int i=0;i<n;i++)
        cout<<"a["<<i<<"]="<<a[i];
cout<<"average waiting time is"<<w<<"\n";
        cout<<"average turn over time is"<<tt<<"\n";
}
int main()
{
        avg ob;
        ob.read();
        ob.awt();
        ob.att();
        ob.display();
return 0;
}

Tuesday 13 December 2011

program for multiplication of two matrices by pointers

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int **p,**q,**s;
    int m1,m2,n1,n2,i,j,k=0,sum;
    printf("enter oreder of 1st matrix:");
    scanf("%d%d",&m1,&n1);
    printf("Enter order of 2nd matrix:");
    scanf("%d%d",&m2,&n2);
    if(m1!=n2)
              printf("Multiplication not possible.");
    else
    {
        printf("Enter elements of 1st matrix:");
        p=malloc(m1*sizeof(int*));
        for(i=0;i<m1;i++)
                p[i]=malloc(n1*sizeof(int));
        for(i=0;i<m1;i++)
                for(j=0;j<n1;j++)
                        scanf("%d",&p[i][j]);
        printf("Enter elements of 2nd matrix:");
        q=malloc(m2*sizeof(int*));
        for(i=0;i<m2;i++)
                q[i]=malloc(m2*sizeof(int));
        for(i=0;i<m2;i++)
                for(j=0;j<n2;j++)
                        scanf("%d",&q[i][j]);
        printf("product is\n");
        s=malloc(m1*sizeof(int*));
        for(i=0;i<m1;i++)
                s[i]=malloc(n2*sizeof(int));
        for(i=0;i<m1;i++)
        {
                for(j=0;j<n2;j++)
                {
                        sum=0;
                        for(k=0;k<m1;k++)
                        {
                                sum=sum+p[i][k]*q[k][j];
                        }
                        s[i][j]=sum;
                        printf("%d ",s[i][j]);
                }
                printf("\n");
        }
}
}

program for addition of two matrices by pointers

#include<stdio.h>
#include<malloc.h>
main()
{
        int **a,**b,**c;
        int m,n,i,j;
        printf("\n enter the size of matrix (m*n): \n");
        scanf("%d %d",&m,&n);
        a = (int **)malloc(sizeof(int*)*m);
        for(i=0;i<m;i++)
                a[i] = (int *)malloc(sizeof(int)*n);
        b = (int **)malloc(sizeof(int*)*m);
        for(i=0;i<m;i++)
                b[i] = (int *)malloc(sizeof(int)*n);
        printf("\n enter the elements of first matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&a[i][j]);
        printf("\n enter the lements of second matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&b[i][j]);
        c = (int **)malloc(sizeof(int*)*m);
        for(i=0;i<m;i++)
                c[i] = (int *)malloc(sizeof(int)*n);
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        c[i][j]=a[i][j]+b[i][j];
        printf("\n the addition matrix is: \n");
                for(i=0;i<m;i++)
                {
                        printf("\n");
                        for(j=0;j<n;j++)
                                printf("%d ",c[i][j]);
                }

}

program for addition of two matrices

#include<stdio.h>
main()
{
        int a[10][10],b[10][10],c[10][10],m,n;
        int i,j;
        printf("\n enter the size of the matrix (m*n): ");
        scanf("%d %d",&m,&n);
        printf("\n enter the elements of first matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&a[i][j]);
        printf("\n enter the lements of second matrix: \n");
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        scanf("%d",&b[i][j]);
        for(i=0;i<m;i++)
                for(j=0;j<n;j++)
                        c[i][j]=a[i][j]+b[i][j];
        printf("\n the addition matrix is: \n");
        for(i=0;i<m;i++)
        {
                printf("\n");
                for(j=0;j<n;j++)
                        printf("%d ",c[i][j]);
        }

}

program to add two integers using pointers

#include<stdio.h>
#include<malloc.h>
main()
{
        int *a,*b,c;
        a=(int*) malloc(sizeof(int));
        b=(int*) malloc(sizeof(int));
        printf("\n enter two numbers: ");
        scanf("%d %d",a,b);
        c=*a+*b;
        printf("\n the addition of the two numbers is %d",c);
}

program to add two integers

#include<stdio.h>
main()
{
 int a,b,sum;
 printf("enter 2 numbers a&b");
 scanf("%d%d",&a,&b);
 printf("entered numbers are a=%d & b=%d",a,b);
 sum=a+b;
 printf("sum is %d",sum);

}

Saturday 3 December 2011

B5(2/4) 4th sem time table


B5(2/4) 4th sem time table
TIMINGS :- AS 3RD SEM (9:00 - 12:30 & 2:00 - 4:30)
Mon: OS,CO,PPL,JAVA - COUNSELLING,SPORTS
Tue: MPI,CO,JAVA,OS - OS LAB (214)
Wed: PPL,MPI,EC,EC - MPI LAB (BATCH I)
Thus: MPI LAB (BATCH II) - JAVA,OS,MPI
Fri: CO,OS,EC,PPL - JAVA Lab (213)
Sat: PPL,MPI,JAVA,CO - LIBRARY

CO :- Smt.D.SUNEETHA
JAVA :- Sri A.PRAVEEN KUMAR
MPI :- Sri B.J.JAIDAN
OS :- Sri A.DIVAKAR
PPL :- Smt B.SOWJANYA
EC :- Sri K.V.R

MPI LAB (BATCH I) :- BJ +BS
MPI LAB (BATCH II) :- TSR+SKR
JAVA LAB :- APK+RS+MP+SVGR
OS LAB :- AD+AS+JH+NMK