The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)

Sunday, June 17, 2012

Finding Vertical Histogram of given set of data 2


#include <iostream>#include <iomanip>#include <algorithm>#include <string>#include<conio.h>using namespace std;
#define VALS 30
int main ( void ){   int h[VALS] = { 1, 2, 4, 8, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2,1, 0, 1, 2, 4, 8, 16, 8, 4, 8, 4, 2, 1, 0 };   int height=0;   int y,x;   cout.unsetf(ios::right);   cout.setf(ios::left);   cout << endl;   for (x=0; x<VALS; x++) height = max(height, h[x]);   for (y=height; y>=1; y--)   {       cout << setw(3) << y << "|";       for (x=0; x<VALS; x++)           if (h[x]>=y) cout << " *"; else cout << "  ";       cout << endl;   }   cout << "---+" << string(VALS*2, '-') << endl;   cout << "   |";   for (x=0; x<VALS; x++)   {       if (x<26)           cout << " " << char('a'+x);       else           cout << " " << char('A'+x-26);   }   cout << endl << endl;   getch();   return 0;}


Friday, June 15, 2012

Finding Vertical Histogram of given set of data


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

int main()
  {
     clrscr();
     int i,j,k,c,num,mrk[10],max,tmp;
     do
     {
     printf("Enter the no. of cases (max. 10): ");
     scanf("%d",&num);
     }while(num<=0 || num>10);
     printf("\n\n");

     max = 0;
     for(i=0;i<num;i++)
     {
 do
      {
printf("\nEnter frequency for Case #%d : ",i+1);
   scanf("%d",&mrk[i]);
 }while( mrk[i]>32766 || mrk[i]<0 );
  if(max < mrk[i])
    max = mrk[i];
     }
     printf("\n\n All data has been collected !!");
     getch();
     clrscr();
     for(i=0;i<num;i++)
     {
      c = (mrk[i]*25)/max;
      //gotoxy(5+(5*i),0);
      for(k=0;k<c;k++)
      {
for(j=0;j<3;j++)
{
gotoxy(5+(5*i)+j,k);
printf("*");

}
      }
      gotoxy(5+(5*i),k);
      printf("%d",mrk[i]);

     }

     getch();
     return 0;
  }

Wednesday, June 13, 2012

Finding Horizontal Histogram of given set of data


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

int main()
  {
     int i,j,k,c,num,mrk[100],max;
     printf("Enter the no. of cases : ");
     scanf("%d",&num);
     printf("\n\n");
   
     max = 0;
     for(i=0;i<num;i++)
     {
 do
      {
        printf("\nEnter frequency for Case #%d : ",i+1);
   scanf("%d",&mrk[i]);
 }while( mrk[i]>32767 || mrk[i]<0 );
  if(max < mrk[i])
    max = mrk[i];
     }
     printf("\n\n All data has been collected !!");
     getch();
   
     printf("\n\n\t\t\t\t HISTOGRAM \n");
     for(i=0;i<num;i++)
     {
      c = (mrk[i]*50)/max;
   
      for(k=0;k<3;k++)
      {
  if(k==1)
  { printf("\n Case #%d      ||  ",i+1); }
  else
  { printf("\n              ||  "); }

  for(j=0;j<c;j++)
    printf("*");

  if(k==1)
   printf("  %d",mrk[i]);
      }
      printf("\n");
      getch();            
     }  
     getch();
     return 0;
  }

Monday, June 11, 2012

Finding Norm of Matrix


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

int main()
  {
    int i,j,m,n;
    int mat[10][10];
    double s,nm;
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);
    s = 0;
    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);    
       
      for(j=0;j<n;j++)
      {
        scanf("%d",&mat[i][j]);    
        s += pow(mat[i][j],2);                  
      }              
    }
    nm = sqrt(s);
    printf("\n\nThe Norm of this matrix : %lf",nm);  
    getch();
    return 0;
  }

Saturday, June 9, 2012

Finding the Saddle Point of Matrix


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

int main()
  {
    int i,j,m,n,min;
    int mat[10][10];
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);

    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);            
      for(j=0;j<n;j++)
       scanf("%d",&mat[i][j]);  
    }
   
    for(i=0;i<m;i++)
    {
      min = 0;        
      for(j=1;j<n;j++)
      {
        if(mat[i][min] > mat[i][j])
         min = j;            
      }    
      for(j=0;j<m;j++)
      {
        if(mat[j][min] > mat[i][min])
         break;                            
      }
      printf("\n Row %d : ",i+1);
      if(j == m)
       printf("Saddle point exists at Column %d",min+1);
      else
       printf("Saddle point doesn't exists");    
    }    
    getch();
    return 0;
  }

Wednesday, June 6, 2012

Finding Skew-Symmetric Matrix


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

int main()
  {
    int i,j,m,n,min;
    int mat[10][10];
    do
    {
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);
    }while(m!=n);

    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);          
      for(j=0;j<n;j++)
       scanf("%d",&mat[i][j]);  
    }
 
    for(i=1;i<m;i++)
    {        
     for(j=0;j<i;j++)
     {
       if(mat[i][j] != -mat[j][i])
        break;            
     }  
    }  
 
    if(i == m && j+1 == i)
     printf("\n\nIt is a Skew-Symmetric Matrix");
    else
     printf("\n\nIt is not a Skew-Symmetric Matrix");
    getch();
    return 0;
  }

Monday, June 4, 2012

Finding Symmetric Matrix


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

int main()
  {
    int i,j,m,n,min;
    int mat[10][10];
    do
    {
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);
    }while(m!=n);

    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);          
      for(j=0;j<n;j++)
       scanf("%d",&mat[i][j]);  
    }
 
    for(i=1;i<m;i++)
    {        
     for(j=0;j<i;j++)
     {
       if(mat[i][j] != mat[j][i])
        break;            
     }  
    }  
 
    if(i == m && j+1 == i)
     printf("\n\nIt is a Symmetric Matrix");
    else
     printf("\n\nIt is not a Symmetric Matrix");
    getch();
    return 0;
  }