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();

}






Friday, 4 November 2016

CODE FOR QUICKSORT IN DATA STRUCTURE

"Nice One Program"

#include<iostream.h>

#include<conio.h>



const int a=10;

void main()

{       clrscr();

  int array[a];

  cout<<"Enter the array :";

  for(int i=0;i<a;i++)

{  cin>>array[i];

  cout<<" ";


}

int k,c;

for(i=1;i<a;i++)

{

  k=array[i];

  c=i-1;


  while(array[c]>k&&c>=0)

  { array[c+1]=array[c];

    c--;

  }

  array[c+1]=k;


  }

     cout<<"\n\n";

  for(i=0;i<a;i++)

  cout<<array[i]<<" ";

getch();

}




Thursday, 22 September 2016

Program To Find Nth Prime Number And Print On The Screen.

"Nice One Program"

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

int main()
{ clrscr();

 int i,j,f=1,c=1,n,a[1000];
 a[0]=2;

 for(i=3;i<=1000;i++)
{ for(j=2;j<i;j++)
 { if(i%j==0)
  { f=0;break;}
    }
    if(f)
    a[c++]=j;
    else
    f=1;

  }
  cout<<"\nEnter which prm numbr:";
  cin>>n;
  cout<<a[n-1];

  getch();

  }



Monday, 18 April 2016

Pangram Checker

Pangram-is a word or Phrase which have all the Alphabets from a to z in it.

"Nice One Program"

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

void main()
{  clrscr();
  char s[100]; int l,i=0,j,f=0;
  cout<<"Enter The String For Checking:\n\n";
  cin.getline(s,100);

  l=strlen(s);
  int t;
  cout<<l<<endl;

 while(s[i])
 {
  s[i]=tolower(s[i]);
   i++;
 }
      cout<<s;
   for(i=97;i<122;i++)
{  for(j=0;j<l;j++)
  { t=s[j];
    if(s[j]=='\0')
    f=0;
    else if(t==i)
    f=1;
  }

 if(f==0)
 break;

}

if(f==1)
cout<<"\n\nPANGRAM";
else
cout<<"\n\nNOT PANGRAM";
getch();

}