Friday, 29 December 2017

Semester Working Days Calculator

Simple C,C++ Project (Program to Calculate Semester Working Days)

"Nice One Program"


#include<iostream.h>
#include<conio.h>

void main()
{     clrscr();
int start,s1,end,e1,yr,tdays;    
                                                 
int tdwork; //total working days
int lp=0;
char *month[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
int days[]={31,28,31,30,31,30,31,31,30,31,30,31}; //days of mnth

cout<<"\n     -->Winter Project<--\n\n";
cout<<"Enter Start and End Month\n";
for(int i=0;i<12;i++)
{
cout<<month[i]<<" As "<<i+1<<endl;
}

cout<<"Enter:";
cin>>start>>end;
{ cout<<"\nEnter Year:"; cin>>yr;
if(yr%4==0) //for leap yr check
lp=1;
}
cout<<"\nEnter Start Date of Month <"<<month[start-1]<<">:";
cin>>s1;
cout<<"\nEnter End Date of Month <"<<month[end-1]<<">:";
cin>>e1;

{
//For TOTALdays
int l1=days[start-1]-s1;
int l2=days[end-1]-e1;
tdays=l1+l2;
for(i=start;i<end-1;i++)
tdays+=days[i];
//***** TOTAL DAYS ARE HERE cout<<"totl days""<tdays;      ****************

}
int tweek;
tweek=tdays/7;

//Removing All Holidays And Other days


{     tdwork=tdays-2*tweek;
      int gzdays[]={4,1,1,3,1,1,1,3,1,3,3,1};   //Gazzeted Holidays Each month

      //Removing leap Year
      {
if(lp)
tdays++;
      }
     int flag=start;      //bcoz of index value

     //Next Lines For Start sem Month Holidays
     { if(e1>=15)
      { if(gzdays[start-1]>=2)
       tdwork=tdwork-(gzdays[start-1]-1);     //that 1 holidays less
      }
      else
      tdwork=tdwork-(gzdays[start-1]);

     }
     //Removing holidays from Inbetween Months
       while(flag<end-1)          // minus 1 coz will work less than index
      {

tdwork=tdwork-gzdays[flag];
flag++;

      }

     //Removing Holidays Of last Month
     {
if(e1>=15)
{
  if(gzdays[end-1]>=2)
  tdwork=tdwork-(gzdays[end-1]-1);
}
else
tdwork=tdwork-(gzdays[end-1]);

     }

}

if(lp)                                //For Leap Year
cout<<"\nTotal Days:"<<tdays<<" (Leap Year)";
else
cout<<"\nTotal Days:"<<tdays;
cout<<"\nTotal Weeks:"<<tweek;


cout<<"\n\nTotal Working Days:"<<tdwork;
cout<<"\nTotal Holidays:"<<tdays-tdwork;
cout<<"\nTotal Gazzeted Holidays:"<<(tdays-tdwork)-(2*tweek);
endl;

getch();
}





Thursday, 7 December 2017

PROGRAM SELECTION SORT

"Nice One Program"


#include<iostream.h>
#include<conio.h>

void main()
{       clrscr();
 int *a,i,n,j,temp;
cout<<"Enter numbr of elements:";
cin>>n;
a=new int[n];
cout<<"enter elemnts:";
for(i=0;i<n;i++)
cin>>a[i];

cout<<"\n\nelements Before sorting:";
for(i=0;i<n;i++)
cout<<a[i]<<" ";

for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;

}


cout<<"\n\nElemnts aftr selction sortng:";
for(i=0;i<n;i++)
cout<<a[i]<<" ";


getch();

}








Sunday, 3 December 2017

CODE For Bubble Sort

"Nice One Program"

#include<iostream.h>
#include<conio.h>

int main()
{    clrscr();
    int n;
//int a[]={7,25,22,5,4,60,20,11,2,9};             //taking cont elements
int *a=NULL;               //dynamic array
cout<<"enter numb of elemnt:";
cin>>n;
a=new int[n];

int temp,i,j,A,B;
cout<<"\n\nenter elements:";
for(i=0;i<n;i++)
cin>>a[i];                                               //Input Values
cout<<"\n\nBefore sorting";


for(i=0;i<n;i++)
cout<<a[i]<<" ";                           //Before


for(i=0;i<n;i++)
for(j=0;j<n-1-i;j++)                 //Sorting
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;

}

}
cout<<endl<<"\nAfter Sorting:";
for(i=0;i<n;i++)
{
cout<<a[i]<<" ";
}


getch();
return 0;
}







Friday, 1 December 2017

CODE FOR TOH(Tower Of Hanoi)

"Nice One Program"


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

TOH(int n,char beg,char aux,char end)
{
if(n>=1){
TOH(n-1,beg,end,aux);
printf("%c to %c \n",beg,end);
TOH(n-1,aux,beg,end);
}
 }
void main()
{     clrscr();
   char A='A',B='B',C='C';
TOH(3,A,B,C);


 getch();

}