Sunday, December 17, 2017

CSITauthority News: December 17, 2017 at 02:02PM

comments 4 Blogger Comments

In recent: Frustrated 8thSem CSIT students calling Dean's Office, IOST, by the minute, to ask when their 6thSem result is going to be published 😂😂😂 ps. In all seriousness, aaja voli samma aucha vanera reply aayeko cha. Tara last week samma Sunday pani vaniyeko thyo. Aaja aaos hopefully.. #fingerscrossed



News mirrored from: CSIT Authority
Read More

Wednesday, August 2, 2017

Entrance form open for B.Sc. CSIT Admission 2074

comments 2 Blogger Comments
Tribhuvan University, Institute of Science and Technology (IOST) announces entrance examination notice for the enrollment in Bachelor of Computer Science and Information Technology (B.Sc. CSIT program) for the academic year 2074 in its constituent and affiliated colleges.
  • Application form fee: Rs. 1200
  • Last date to submit Application form: 2074 Bhadra 14
  • Last date to submit Application form(with Double fee): 2074 Bhadra 19
  • Entrance exam date: 2074 Bhadra 24 ( 12AM to 2PM)
BONUS NEWS!! ST. XAVIER'S COLLEGE ENTRANCE EXAM IS GOING TO BE HELD ON 10th September 2017. This college conducts an additional internal exam. Please hurry up to get your entrance examination form if you are interested.

Currently 54 Colleges offers B.Sc. CSIT program in Nepal with affiliation from Tribhuvan University. For details, eligibility, requirements, support and so on regarding Admission and the process, we highly recommend you to visit our Admission Page.
Official Notice by TU, IOST

TU Admission Form 2074 :

TU Form:
TU IOST Admission Form 2074

Here are some MODEL QUESTIONS to help you in your TU IOST Entrance Examination for BSc.CSIT Admission. We have provided both NEW and OLD format because although the old one is obsolete, it is not completely useless. Refer it after finishing the NEW model.

MODEL QUESTIONS(OLD + NEW)

Model Questions(NEW FORMAT):
TU IOST Model(New Format) Questions
Model Questions(OLD FORMAT):
TU IOST Model(Old Format) Questions
Read More

Tuesday, June 6, 2017

BSc. CSIT 7th Semester TU Board Exam Routine 2074

comments 0 Blogger Comments
Old Notices
No older notices available

Read More

Thursday, June 1, 2017

The CSIT Song

comments 0 Blogger Comments
Couldn't resist sharing. Original song at this link
Read More

Saturday, April 1, 2017

Some common Numerical Method Programs for 3rd Semester BSc. CSIT students

comments 0 Blogger Comments
Pro tip: If you are searching for a speciic program, hit Ctrl+F to search faster. This is quite a long list.

1. Program to find Rootof a fuction by using Bisection method
/*program to find Rootof a fuction by using Bisection method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
#define E 0.00001
#define f(x) x*x-4*x-10
void main()
{
 clrscr();
   int count=0;
   float x0,x1,x2,f0,f1,f2;
   printf("Enter the value of x1\n");
   scanf("%f",&x1);
   printf("Enter the value of x2\n");
   scanf("%f",&x2);
   f1=f(x1);
   f2=f(x2);
   if (f1*f2>0)
   printf("Solution does not exit");
   else
   {
 begin:
 x0=(x1+x2)/2;
 f0=f(x0);
 if((f1*f0)<0)
  x2=x0;
      else
      {
 x1=x0;
  f1=f0;
      }
      if((fabs(x2-x1)/x1)<E)
      {
 x0=(x1+x2)/2;
  printf("\nRoor=%f",x0);
  printf("\nFuctional value =%f",count);
  printf("\nIteration steps =%d",count);
      }
      else
      {
 count ++;
  goto begin;
      }
   }
   getch();
}
  

2. Program to find Rootof a fuction by using Newton Raption method
/*program to find Rootof a fuction by using Newton Raption method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 10
#define E 0.0001
#define f(x)  x*x*x-3*x-2
#define fd(x)  3*x*x-3
void main()
{
    clrscr();
    int count=0;
    float x0,x1,fx,fdx;
    printf("\nEnter the initial value of x0\n");
    scanf("%f",&x0);
begin:
    printf("\nStep %d",count+1);
    fx=f(x0);
    printf("\nvalue of fx%d=%f",count,fx);
    fdx=fd(x0);
    printf("\nvalue of fdx%d= %f",count,fdx);
    x1=x0-(fx/fdx);
    if((fabs(x1-x0)/x1)<E)
    {
        printf("\nRoot=%f",x1);
        printf("\nThe fuction value=%f",f(x1));
        printf("\nNo. of Iritation steps=%d",count);
    }
    else
    {
        x0=x1;
        count ++;
        if (count<MAX)
        {
            goto begin;
        }
        else
        {
            printf("It takes more than 10 steps So solution does not coverse");
        }
    }
    getche();
}

  

2. Program to Rootof a fuction by using Newton Raption method (Alternate)
/*program to find Rootof a fuction by using Newton Raption method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 10
#define E 0.0001
#define f(x) x*x-3*x+2
#define fd(x) 2*x-3
void main()
{
    clrscr();
    int count=0;
    float x0,x1,fx,fdx;
    printf("\nEnter the initial value of x0");
    scanf("%f",&x0);
begin:
    fx=f(x0);
    fdx=fd(x0);
    x1=x0-(fx/fdx);
    if((fabs(x1-x0)/x1)<E)
    {
        printf("\nRoot=%f",x1);
        printf("\nThe fuction value=%f",f(x1));
        printf("\nNo. of Iritation steps=%d",count);
    }
    else
    {
        x0=x1;
        count ++;
        if (count<MAX)
        {
            goto begin;
        }
        else
        {
            printf("It takes more than 10 steps So solution does not coverse");
        }
    }
    getche();
}

  

3. Program to find Root of a fuction by using Secant method
/*program to find Root of a fuction by using Secant method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 10
#define E 0.0001
#define f(x) x*x-4*x-10
void main()
{
    clrscr();
    int count=0;
    float x1,x2,x3,f1,f2;
    printf("\nEnter the two value of x1 and x2\n");
    scanf("%f%f",&x1,&x2);
begin:
    f1=f(x1);
    f2=f(x2);
    x3=x2-f2*(x2-x1)/(f2-f1);
    if((fabs(x3-x2)/x2)<E)
    {
        printf("\nRoot=%f",x3);
        printf("\nNo. of Iteration steps=%d",count);
    }
    else
    {
        x1=x2;
        x2=x3;
        f1=f2;
        f2=f(x3);
        count ++;
        if (count<MAX)
        {
            goto begin;
        }
        else
        {
            printf("It solution does not coverge");
        }

    }
    getche();
}

  

4. Program to find Rootof a fuction by using Fixed point method
/*program to find Rootof a fuction by using Fixed point method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
#define E 0.001
#define g(x) exp(x)/3
void main()
{
    clrscr();
    int count=0;
    float x0,x1,error;
    printf("\nEnter the initial guess value of x0\n");
    scanf("%f",&x0);
begin:
    x1=g(x0);
    error=fabs(x1-x0);
    if(error<=E)
    {
        printf("\nThe root is %f",x1);
        printf("\nThe error value %f",error);
        printf("\nThe iteration steps is %d",count);
    }
    else
    {
        x0=x1;
        count ++;
        if (count<MAX)
        {
            goto begin;
        }
        else
        {
            printf("It solution does not coverge");
        }

    }
    getch();
}

  

5. Demonstrate Lagranges Interpolation
//Lagranges interpolation
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 10
void main()
{
    clrscr();
    int i,j,n;
    float x[MAX],f[MAX],sum=0,pro,xp,fp;
    printf("Enter the number of data points:\n");
    printf("\nn= ");
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        printf("\nInput the data points for x[%d]&f[%d]",i,i);
        printf("\nx[%d]= ",i);
        scanf("%f",&x[i]);
        printf("\nf[%d]= ",i);
        scanf("%f",&f[i]);
    }
    printf("\nInput the specied value of x:");
    scanf("%f",&xp);
    for(i=0; i<=n; i++)
    {
        pro=1;
        for(j=0; j<=n; j++)
        {
            if(i!=j)
                pro=pro*(xp-x[j])/(x[i]-x[j]);
        }
        sum=sum+pro*f[i];
    }
    fp=sum;
    printf("\nThe required functional value at %f=%f",xp,fp);
    getch();
}

  

6. Demonstrate Newton Interpolation
// NEWTON INTERPOLATION
#include<stdio.h>
#include<math.h>
#include<conio.h>
#define MAX 10
void main()
{
    int i,j,n;
    float xp,fp,pro,sum,a[MAX],f[MAX],x[MAX],d[MAX][MAX];
    printf("\nInput the number of data points:");
    printf("\nn=");
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        printf("\nInput the data of x[%d]&f[%d]:",i,i);
        printf("\nx[%d]=",i);
        scanf("%f",&x[i]);
        printf("\nf[%d]=",i);
        scanf("%f",&f[i]);
    }
    for(i=1; i<=n; i++)
        d[i][1]=f[i];
    for(j=2; j<=n; j++)
        for(i=1; i<=n-j+1; i++)
            d[i][j]=(d[i+1][j-1]-d[i][j-1])/(x[i+j-1]-x[i]);
    for(j=1; j<=n; j++)
        a[j]=d[1][j];
    printf("\nInput the value of xp point:");
    printf("\nxp=");
    scanf("%f",&xp);
    sum=a[1];
    for(i=2; i<=n; i++)
    {
        pro= 1.0;
        for(j=1; j<=i-1; j++)
            pro=pro*(xp-x[j]);
        sum=sum+a[i]*pro;
    }
    fp=sum;
    printf("\n At xp=%f is %f",xp,fp);
    getch();
}
  

7. Demonstrate Least Square Method
// Least square method
#include<stdio.h>
#include<math.h>
#include<conio.h>
#define MAX 10
void main()
{
    int i,n;
    float a0,a1;
    float x[MAX],y[MAX],sumx=0.0,sumy=0.0,sumxy=0.0,sumxsq=0.0;
    printf("***Least square method***" );
    printf("\nInput the number of data points:");
    printf("\nn=");
    scanf("%d",&n);
    printf("Enter the data sets one after another:");
    for(i=0; i<n; i++)
    {
        // printf("\nInput the data of x[%d]&f[%d]:",i,i);
        printf("\nx[%d]=",i);
        scanf("%f",&x[i]);
        printf("\ny[%d]=",i);
        scanf("%f",&y[i]);
        sumx+=x[i];
        sumy+=y[i];
        sumxy+=x[i]*y[i];
        sumxsq+=x[i]*x[i];
    }
    a0=(sumy*sumxsq-sumx*sumxy)/(n*sumxsq-pow(sumx,2));
    a1=(n*sumxy-sumx*sumy)/(n*sumxsq-pow(sumx,2));
    printf("The equation of line:\n");
    printf("\n y=%fx+%f",a1,a0);
    getch();
}
  

8. Program to find Integration of given function by using Trapezoidal rule
/*program to find Integration of given funtion by using Trapezoidal rule*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define f(x) x*x*x+1
void main()
{
    clrscr();
    float a,b,h,It;
    printf("\nEnter initial value of X:");
    scanf("%f",&a);
    printf("\nEnter  Final  value of X:");
    scanf("%f",&b);
    h=(b-a)/2;
    It =h*(f(a)+f(b));
    printf("\nThe integration value of function :%f",It);
    getch();
}

  

9. Program to find Integration of given tabulated data using Composite Trapezoidal rule*
/*program to find Integration of given tabulated data using  Composit Trapezoidal rule*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define max 15
void main()
{
    clrscr();
    int n,n1,n2,i;
    float a,b,h,sum,ict,x[max],y[max];
    printf("\nEnter the number of data points:");
    printf("\nn=");
    scanf("%d",&n);
    printf("\nInput the values set by set");
    for(i=1; i<=n; i++)
    {
        printf("\nX%i=",i);
        scanf("%f",&x[i]);
        printf("\nF(x%i)=",i);
        scanf("%f",&y[i]);
    }
    printf("\nInput the initial value.");
    printf("\na=");
    scanf("%f",&a);
    printf("\nInput the final value.");
    printf("\nb=");
    scanf("%f",&b);
    h=x[2]-x[1];
    n1= (int)(fabs(a-x[1])/h+1.5);
    n2= (int)(fabs(b-x[1])/h+1.5) ;
    sum=0.0;
    for(i=n1; i<=n2; i++)
        sum =sum+y[i]+y[i+1];
    ict= sum*h/2.0;
    printf("\nIntegral from %f to %f is %f\n",a,b,ict);
    getche();
}
  

10. Program to find Integration of given funtion by using Composite Trapezoidal rule
/*program to find Integration of given funtion by using composit Trapezoidal rule*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
    clrscr();
    int i,n;
    float a,b,h,sum,Ict;
    float F(float x);
    printf("Enter the initial value of a:");
    scanf("%f",&a);
    printf("\nEnter the Final  value of b: ");
    scanf("%f",&b);
    printf("\nEnter the segment width:");
    scanf("%f",&h);
    n=(b-a)/h;
    sum =(F(a)+F(b))/2.0;
    for(i=1; i<n-1; i++)
    {
        sum= sum +F(a+i*h);
    }
    Ict=sum*h;
    printf("\nThe integration between %f and %f at h=%f is %f",a,b,h,Ict);
    getch();
}
float F(float x)
{
    float f;
    f=1-exp(-x/2.0) ;
    return (f);
}

  

11. Program to find Integration of given funtion by using Simson's 1/3 rule
/*program to find Integration of given funtion by using Simson's 1/3 rule*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define F(x) 1-exp(-(x)/2.0)
void main()
{
 clrscr();
   int n,m,i;
   float a,b,h,sum,Ics,x,f1,f2,f3;
   printf("Enter initial value of X:");
   printf("\na=");scanf("%f",&a);
   printf("\nEnter  Final  value of X:");
   printf("\nb=");scanf("%f",&b);
   printf("\nEnter number of segments (Even number):");
   printf("\nN=");scanf("%d",&n);
   h=(b-a)/n;
   m=n/2;
   sum =0.0;
   x=a;
   f1=F(x);
   for(i=1;i<m;i++)
   {
    f2=F(x+h);
      f3=F(x+2*h);
      sum=sum+f1+4*f2+f3;
      f1=f3;
      x=x+2*h;
   }
   Ics=sum *h/3.0;
   printf("\nIntegral from %f to %f\n",a,b);
   printf("When h=%f is %f \n",h,Ics);
   getch();
}
  

12. Program to find Integration of given funtion by using Simson's 1/8 rule
/*program to find Integration of given funtion by using Simson's 1/8 rule*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define F(x) (x*x*x+1)
void main()
{
    clrscr();
    float a,b,h,Is;
    printf("\nEnter initial value of X:");
    scanf("%f",&a);
    printf("\nEnter  Final  value of X:");
    scanf("%f",&b);
    h=(b-a)/3;
    Is=3*h*(F(a)+3*F(a+h)+3*F(a+2*h)+F(b))/8;
    printf("\nIntegral from %f to %f\n",a,b);
    printf("Integration is %f \n",Is);
    getch();
}

  

13. Program to solve Integration equation by using Gauss Integration Method for n=2 interpolating point
/*program to solve Integration equation by using gauss integration method for
n=2 interpolating point*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define f(x) exp(x)
void main()
{
    clrscr();
    int n=2,i;
    float a,b,w[2],z[2],x[2],Ig =0.0;
    printf("\nInput initial value of x:");
    printf("\na=");
    scanf("%f",&a);
    printf("\nInput final value of x:");
    printf("\nb=");
    scanf("%f",&b);
    w[0]=1.0;
    w[1]=1.0;
    z[0]=-0.5773502;
    z[1]=0.5773502;
    for (i=0; i<n; i++)
        x[i]=((b-a)/2)* z[i]+((b+a)/2);
    for(i=0; i<n; i++)
        Ig +=((b-a)/2)*(w[i]*f(z[i]));
    printf("\nIntegral from %f to %f is %f\n",a,b,Ig);
    getche();
}

  

14. Program to solve Integration equation by using gauss integration method for n=3 interpolating point
/*program to solve Integration equation by using gauss integration method for
n=3 interpolating point*/
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
#include&lt;math.h&gt;
#define f(x) exp(x)
void main()
{
    clrscr();
    int n=3,i;
    float a,b,w[3],z[3],x[3],Ig =0.0000;
    printf("\nInput initial value of x:");
    printf("\na=");
    scanf("%f",&amp;a);
    printf("\nInput final value of x:");
    printf("\nb=");
    scanf("%f",&amp;b);
    w[0]=0.55556;
    w[1]=0.88889;
    w[2]=0.55556;
    z[0]=-0.77460;
    z[1]=0.00;
    z[2]=0.77460;
    for (i=0; i&lt;n; i++)
        x[i]=((b-a)/2)* z[i]+((b+a)/2);
    for(i=0; i&lt;n; i++)
        Ig +=((b-a)/2)*(w[i]*f(z[i]));
    printf("\nIntegral from %f to %f is %f\n",a,b,Ig);
    getche();
}
  

15. Demonstrate Euler Method
//Eluer method
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define f(x,y) 2*y/x
void main()
{
    clrscr();
    int i,n;
    float x,y,h,xp,dy;
    printf("Input initial value of x and y");
    scanf ("%f%f",&x,&y);
    printf("Input X-value at which Y is required :\n");
    scanf("%f",&xp);
    printf("Input  step size:\n");
    scanf("%f",&h);
    n=((xp-x)/h+0.5);
    for (i=1; i<=n; i++)
    {
        dy=h*f(x,y);
        x=x+h;
        y=y+dy;
        printf("x=%f and y=%f\n",x,y);
    }
    printf("\n Value of y at x =%f is %f",x,y);
    getche();
}

  

16. Demonstrate Heuns Method
// Heuns method
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define max 15
void main()
{
    clrscr();
    int n,i;
    float x,y,xp,h,m1,m2;
    float func(float,float);
    printf("\n***Solution of Heuns method***");
    printf("\nEnter the initial value of x \n");
    scanf("%f",&x);
    printf("\nEnter the initial value of y \n");
    scanf("%f",&y);
    printf("\nInput x at which y is required");
    scanf("%f",&xp);
    printf("\nInput step size");
    scanf("%f",&h);
    n=(int)((xp-x)/h+0.5);
    for(i=1; i<=n; i++)
    {
        m1=func(x,y);
        m2=func(x+h,y+m1*h);
        x=x+h;
        y=y+0.5*h*(m1+m2);
        printf("%5d %10.6f %10.6f\n",i,x,y);
    }
    printf("\nThe value of y at x=%f is %f\n",x,y);
    getch();
}
float func(float x,float y)
{
    float f;
    f=2.0*y/x;
    return(f);
}

  

17. Demonstrate Runge-Kutta Method
#include <stdio.h>
#include <conio.h>
#include <math.h>
//#define f(x,y) (2.0*y/x)
void main()
{
  clrscr();
  int n,i;
  float x,y,xp,h;
  float m1,m2,m3,m4;
  float func(float , float );
  printf("Input initial value of x and y");
  scanf ("%f%f",&x,&y);
  printf("Input X-value at which Y is required :\n");
  scanf("%f",&xp);
  printf("Input  step size:\n");
  scanf("%f",&h);
  n=(int)((xp-x)/h+0.5);
  for (i=1;i<=n;i++)
  {
    m1=func(x,y);
      m2=func(x+0.5*h,y+0.5+m1*h);
      m3=func(x+0.5*h,y+0.5+m2*h);
      m4=func(x+h,y+m3*h);
      x=x+h;
      y=y+(m1+2.0*m2+2.0*m3+m4)*h/6.0;
      printf("x=%f and y=%f\n",x,y);
  }
  printf("\n Value of y at x=%f is %f",x,y);
    getche();
}
float func(float x, float y)
  {
    float f;
      f=x*x+y*y;
      return(f);
  }
  

18. Runge-Kutta (Alternate)
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define f(x,y) 2.0*y/x
void main()
{
    clrscr();
    int i,n;
    float x,y,xp,h;
    float m1,m2,m3,m4;
    printf("Input initial value of x and y");
    scanf ("%f%f",&x,&y);
    printf("Input X-value at which Y is required :\n");
    scanf("%f",&xp);
    printf("Input  step size:\n");
    scanf("%f",&h);
    n=(int)((xp-x)/h+0.5);
    for (i=1; i<=n; i++)
    {
        m1=f(x,y);
        m2=f(x+0.5*h,y+(m1*h*0.5));
        m3=f(x+0.5*h,y+(m2*h*0.5));
        m4=f(x+h,y+m3*h);
        x=x+h;
        y=y+((m1+2.0*m2+2.0*m3+m4)*h)/6.0;
        printf("x=%f and y=%f\n",x,y);
    }
    printf("\n Value of y at xp =%f is %f",x,y);
    getche();
}

  

Read More

Program to find Root of a fuction by using Newton Raphson method

comments 0 Blogger Comments

Program to find Root of a fuction by using Newton Raphson method
/*program to find Rootof a fuction by using Newton Raphson method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 10
#define E 0.0001
#define f(x)  x*x*x-3*x-2
#define fd(x)  3*x*x-3
void main()
{
    clrscr();
    int count=0;
    float x0,x1,fx,fdx;
    printf("\nEnter the initial value of x0\n");
    scanf("%f",&x0);
begin:
    printf("\nStep %d",count+1);
    fx=f(x0);
    printf("\nvalue of fx%d=%f",count,fx);
    fdx=fd(x0);
    printf("\nvalue of fdx%d= %f",count,fdx);
    x1=x0-(fx/fdx);
    if((fabs(x1-x0)/x1)<E)
    {
        printf("\nRoot=%f",x1);
        printf("\nThe fuction value=%f",f(x1));
        printf("\nNo. of Iritation steps=%d",count);
    }
    else
    {
        x0=x1;
        count ++;
        if (count<MAX)
        {
            goto begin;
        }
        else
        {
            printf("It takes more than 10 steps So solution does not coverse");
        }
    }
    getche();
}

  

Read More

Program to find Root of a fuction by using Bisection method

comments 0 Blogger Comments

Program to find Rootof a fuction by using Bisection method
/*program to find Rootof a fuction by using Bisection method*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
#define E 0.00001
#define f(x) x*x-4*x-10
void main()
{
  clrscr();
   int count=0;
   float x0,x1,x2,f0,f1,f2;
   printf("Enter the value of x1\n");
   scanf("%f",&x1);
   printf("Enter the value of x2\n");
   scanf("%f",&x2);
   f1=f(x1);
   f2=f(x2);
   if (f1*f2>0)
   printf("Solution does not exit");
   else
   {
  begin:
  x0=(x1+x2)/2;
  f0=f(x0);
  if((f1*f0)<0)
    x2=x0;
      else
      {
  x1=x0;
   f1=f0;
      }
      if((fabs(x2-x1)/x1)<E)
      {
  x0=(x1+x2)/2;
   printf("\nRoor=%f",x0);
   printf("\nFuctional value =%f",count);
   printf("\nIteration steps =%d",count);
      }
      else
      {
  count ++;
   goto begin;
      }
   }
   getch();
}
  

Read More

Thursday, March 30, 2017

CSITauthority News: March 30, 2017 at 09:28PM

comments 0 Blogger Comments

#3rdSem results out. Pass huney walas lai badhai. Back haru note it http://ift.tt/1q8Ru2E



News mirrored from: CSIT Authority
Read More

Sunday, February 19, 2017

Semester 6 Assignment Dump

comments 0 Blogger Comments
Work together, get more resource material, finish faster and slay all assignments!

Teamwork Panel:


Current Assignments:


The naming format CSC-351-SE-L-05 provides the following information: Software Engineering Lab Assignment#5.
Other abbreviations indicate the following: L=LAB Assignment, T=Theory Assignment, HC=HardCopy, SC=Softcopy, R=Report
*Similar Naming convention will be used to complete and upload assignments. Assignments can be viewed and uploaded in the panel below this notice.

Upload Section:

uploaded assignments
Assignments will appear below after being uploaded

To upload your own assignment, read this note properly:
{SubjectCode}-{SubjectAbbr}-{LABorTHEORY}-{AssignmentNumber}-{[YourIDoptional]}
example, for Software Engineering Lab Assignment#5, use::
CSC-351-SE-L-05.docx OR, CSC-351-SE-L-05-013BSCCSIT055.docx [Giving your ID is optional].
List of Subject Codes
CSC 351: Software Engineering(SE)
CSC 352: Compiler Design and Construction(CDC)
CSC 353: Web Technologies(WebTech)
CSC 354: Real Time System(RTS)
CSC 355: Knowledge Management(KM)
CSC 356: Fundamentals of E-Commerce(Ecom)
CSC 357: Society and Ethics in Information Technology(SEIT)
CSC 358: Automation and Robotics(AuRo)
CSC 359: Digital System Design(DSD)
CSC 360: Net Centric Computing(NCC)
CSC 361: Web Centric Computing(WCC)
CSC 362: Embedded System Programming(ESP)
CSC 363: Image Processing
Click to Upload your Assignments
Read More

Friday, September 2, 2016

Implement DFA that accepts only 'int' or 'integer'

comments 0 Blogger Comments
This is a program in Java which maps the DFA for input string where the string must be 'int' or 'integer' to be accepted. It is also an excellent example for DFAs with deadends. Since definition of DFA is a trivial topic for this question, any pre-requisite information about DFA that you might need is available at this site.

Procedure:
  1. Make a state diagram for DFA accepting 'int' or 'integer'

    Edit: I seem to have made a small mistake while making the state diagram. q3 and q7 are actually FINAL STATES and those two states should have double circle instead of single one :)

  2. Trace a state-table with information from (1)
    i n t e g r
    q0 q1 q8 q8 q8 q8 q8
    q1 q8 q2 q8 q8 q8 q8
    q2 q8 q8 q3 q8 q8 q8
    *q3 q8 q8 q8 q4 q8 q8
    q4 q8 q8 q8 q8 q5 q8
    q5 q8 q8 q8 q6 q8 q8
    q6 q8 q8 q8 q8 q8 q7
    *q7 q8 q8 q8 q8 q8 q8
    q8 q8 q8 q8 q8 q8 q8
  3. Write a program to emulate the behavior of given DFA with the rules provided by (2)

SOURCE CODE:

public class DFAwithdeadend {
    public static void main(String[] args) {
        // Implement DFA that accepts 'int' or 'integer'
        int count;
        String state_now="q0",
               final_state1="q3",final_state2="q7";
        Scanner sc= new Scanner(System.in);
        System.out.print("Enter a string to test:");
        String string= sc.nextLine();
        HashMap i = new HashMap();
        HashMap n = new HashMap();
        HashMap t = new HashMap();
        HashMap e = new HashMap();
        HashMap g = new HashMap();
        HashMap r = new HashMap();
        HashMap deadend = new HashMap();
        i.put("q0","q1");
        n.put("q1","q2");
        t.put("q2","q3");
        e.put("q3","q4");
        g.put("q4","q5");
        e.put("q5","q6");
        r.put("q6","q7");
        for(count=0;count<=8;count++){
            String rem_state="q"+count;
            if (count!=0)
                i.put(rem_state,"q8");
            if (count!=1)
                n.put(rem_state,"q8");
            if (count!=2)
                t.put(rem_state,"q8");
            if (count!=3 && count!=5)
                e.put(rem_state,"q8");
            if (count!=4)
                g.put(rem_state,"q8");
            if (count!=6)
                r.put(rem_state,"q8");
            deadend.put(rem_state, "q8");
        }
        System.out.print("Tracing DFA..\nstart:q0");
        for(count=0;count<string.length();count++){
            if(string.charAt(count)=='i'){
              state_now=(String)i.get(state_now);
            }
            else if(string.charAt(count)=='n'){
                state_now=(String)n.get(state_now);
            }
            else if(string.charAt(count)=='t'){
                state_now=(String)t.get(state_now);
            }
            else if(string.charAt(count)=='e'){
                state_now=(String)e.get(state_now);
            }
            else if(string.charAt(count)=='g'){
                state_now=(String)g.get(state_now);
            }
            else if(string.charAt(count)=='r'){
                state_now=(String)r.get(state_now);
            }
            else{
                state_now=(String)deadend.get(state_now);
            }
            System.out.print("-->"+state_now); 
        }
        if(state_now.equals(final_state1)||state_now.equals(final_state2)){
            System.out.println("\nConclusion: This string is accepted in DFA");
        }
        else{
            System.out.println("\nConclusion: This string is not accepted in DFA");
        }
    }
}

OUTPUT:
when string is accepted in DFA:


when string is rejected in DFA:

If you have any doubt, please feel free to inquire.

Read More

Wednesday, August 31, 2016

DFA to accept string with even a and even b

comments 0 Blogger Comments

Procedure:
1. Make a state diagram for DFA having even a and even b

2. Trace a state-table with information from (1)
3. Write a program to emulate the behavior of given DFA with the rules provided by (2)
If you need further elaboration in this topic^(i.e. Procedure), please drop a comment and we'll post DFA state-diagram and state-table also.
public class DfaEvenAB {
    public static void main(String[] args) {
        //Implementing DFA with even a and b
        String state="q0";
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the String:");
       String exp=sc.nextLine();
       HashMap a = new HashMap();
       HashMap b = new HashMap();
       a.put("q0","q1");
       a.put("q1","q0");
       a.put("q2","q3");
       a.put("q3","q2");
       b.put("q0","q3");
       b.put("q1","q2");
       b.put("q2","q1");
       b.put("q3","q0");
       
        System.out.print("Tracing DFA:\nstart=q0");
        for(int i=0;i<exp.length();i++){
            String str=""+exp.charAt(i);
            if(str.equals("a")){
                state=(String)a.get(state);
            }else if(str.equals("b")){
                state=(String)b.get(state);
            }
            System.out.print("-->"+state);
        }
        if(state.equals("q0")){
            System.out.println("\nString Accepted");
        }else{
            System.out.println("\nString not Accepted. Try another String.");
        }
    }
}

Output:


When String is Accepted:

When String is not accepted:
Read More

Tuesday, August 30, 2016

Implement DFA ending with 'abb'

comments 0 Blogger Comments
This is a program in Java which maps the DFA for input string where the ending substring must be 'abb' to be accepted. Since definition of DFA is a trivial topic for this question, any pre-requisite information about DFA that you might need is available at this site.

Procedure:

  1. Make a state diagram for DFA ending with abb
  2. Trace a state-table with information from (1)
  3. Write a program to emulate the behavior of given DFA with the rules provided by (2)
If you need further elaboration in this topic^(i.e. Procedure), please drop a comment and we'll post DFA state-diagram and state-table also.


SOURCE CODE:

public class DfaFinder {
    public static void main(String[] args) {
        // Implement DFA ending with abb
        String state_now="q0";
        Scanner sc= new Scanner(System.in);
        String string= sc.nextLine();
        HashMap a = new HashMap();
        HashMap b = new HashMap();
        a.put("q0","q1");
        a.put("q1","q1");
        a.put("q2","q1");
        a.put("q3","q1");
        b.put("q0","q0");
        b.put("q1","q2");
        b.put("q2","q3");
        b.put("q3","q0");
        System.out.print("Tracing DFA..\nstart:q0");
        for(int i=0;i<string.length();i++){
            if(string.charAt(i)=='a'){
              state_now=(String)a.get(state_now);
            }
            else if(string.charAt(i)=='b'){
                state_now=(String)b.get(state_now);
            }
            System.out.print("-->"+state_now); 
        }
        if(state_now.equals("q3")){
            System.out.println("\nConclusion: This string is accepted in DFA");
        }
        else{
            System.out.println("\nConclusion: This string is not accepted in DFA");
        }
    }
}

OUTPUT:
when string is accepted in DFA:


when string is rejected in DFA:


If you have any doubt, please feel free to inquire.

Read More

Monday, August 29, 2016

CSC 354 - Real-Time System Assignments

comments 0 Blogger Comments
*Please note:This page is exclusively made for students of SXC 6th Sem(2013 Batch) only.
Easy-to-remember Short-link to this page is http://bit.ly/rtsassignments
Submit RTS Assignments
Read More

Saturday, August 27, 2016

CSC 360 - Net Centric Computing Assignments

comments 0 Blogger Comments
*Please note:This page is exclusively made for students of SXC 6th Sem(2013 Batch) only.
Easy-to-remember Short-link to this page is http://bit.ly/netcentricassignments
Submit NetCentric Assignments
Read More

CSC 353 - Web Technologies Assignments

comments 0 Blogger Comments
*Please note:This page is exclusively made for students of SXC 6th Sem(2013 Batch) only.
Easy-to-remember Short-link to this page is http://bit.ly/webtechassignments
Submit WebTech Assignments
Uploaded files:
Your files will appear below shortly after being uploaded.
Please follow this format:
subCode-subAbbr-labOrTheory-assignmentNumber-rollNo when you upload a file
Read More

CSC 351 - Software Engineering Assignments

comments 0 Blogger Comments
*Please note:This page is exclusively made for students of SXC 6th Sem(2013 Batch) only.
Easy-to-remember Short-link to this page is http://bit.ly/seassignments
Submit Software Engineering Assignments
Read More

Wednesday, August 24, 2016

Fix: HAX Kernel Module is not installed

comments 0 Blogger Comments
 
As versatile and easy-to-use Android studio is, it has a set of its own petty little problems that sometimes end up taking a lot of time to fix. This is because all the fixes are available in documentations, changelogs or, special forums which may not be easily found. One such problem is the "HAX Kernel Module not installed" message that keeps popping when you try to use that emulator you were sure that you built your app to emulate. 
 
Many of us have faced this problem while using Android Studio at one point or the other. This is a definite fix to that problem as cited on one of stackoverflow questions: 

If you are running a modern Intel processor make sure HAXM (Intel® Hardware Accelerated Execution Manager) is installed:
  1. In Android SDK Manager, ensure the option is ticked (and then installed)
  2. Run the HAXM installer via the path below:
    1. your_sdk_folder\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm.exe 
    2. or 
    3. your_sdk_folder\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm-android.exe
For AMD CPUs (or older Intel CPUs without VT-x technology), you will not be able to install this and the best option is to emulate your apps using Genymotion. See: Intel's HAXM equivalent for AMD on Windows OS

Here is a helpful video to solve this problem: 
;


Read More

Sunday, August 14, 2016

SXC 6th Semester 2016 Daily Routine

comments 0 Blogger Comments
   
SXC 6th Sem 2016 Daily Routine
PERIOD 1st Period2nd Period3rd Period4th Period
DAY 6:15 to 7:157:45 to 9:059:30 to 11:0011:15 to 12:40
Sunday
Compiler(LAB-C)
10 min
break
SE
Lunch
break
10 min
break
Monday
WT
RTS(LAB-C)
SE(LAB-C)
Tuesday
Compiler
WT
Elective(LAB)
Elective(FIELD/LAB)
Wednesday
WT
RTS
RTS(LAB-C)
Thursday
Compiler
WT(LAB-B)
Elective(LAB B+D)
SE(LAB-B)
Friday
RTS
Compiler(LAB-C)
SE
Elective(FIELD/LAB)
SXC 6th Semester Routine 2016
*Effective from 02nd September 2016
*1 period duration = 90minutes

*Optimized for viewing in screens above 800px in width

1stpd.2ndpd.3rdpd.4thpd.
SunCompiler(LAB-C)
10min
break
SE
Lunch
break
10min
break
MonWTRTS(LAB-C)SE(LAB-C)
TueCompilerWTElective(LAB)Elective(FIELD/LAB)
WedWTRTSRTS(LAB-C)
ThuCompilerWT(LAB-B)Elective(LAB B+D)SE(LAB-B)
FriRTSCompiler(LAB-C)SEElective(FIELD/LAB)
6th Semester Daily Routine SXC*::
Sun:: Compiler(LAB-C), SE
Mon:: WT, RTS(LAB-C), SE(LAB-C)
Tue:: Compiler, WT, Elective(LAB), Elective(FIELD/LAB)
Wed:: WT, RTS, RTS(LAB-C)
Thu:: Compiler,WT(LAB-B), Elective(LAB B+D), SE(LAB-B)
Fri:: RTS, Compiler(LAB-C), SE, Elective(FIELD/LAB)

*Optimized for viewing in 690px+ and 800px+ (Recommended)
Read More

Saturday, August 13, 2016

BSc.CSIT Batch 2073 Admissions OPEN in St. Xavier's College, Maitighar

comments 0 Blogger Comments
B.Sc. CSIT: TU FORM: 
Deadline: Bhadra 24th, 
Entrance: 2073 Ashoj 12th, 11AM - 1 PM
ST. XAVIER'S COLLEGE ENTRANCE EXAM IS GOING TO BE HELD ON 29th September 2016 (२०७३ असोज १३ बिहीवार). This college conducts an additional internal exam. Please hurry up to get your entrance examination form if you are interested.
SXC also conducts a seperate college entrance examination besides the standard TU IOST entrance exam. The requirement for minimum eligibilty is that candidates must successfully pass the SXC Entrance exam. The performance in TU Entrance exam may or may not affect the placement of a candidate on the interview list but performing well in the internal entrance exam is paramount. SXC does not have a scholarship program for top scorers in TU IOST entrance exam. However, There are several good colleges that consider good performance in TU IOST exam for a scholarship program and/or subsidy in fee. [know more...]
Take a look at SXC's notice:
Tribhuvan University, Institute of Science and Technology (TU, IOST) has opened its entrance forms for • B.Sc. CSIT: TU...
Posted by St. Xavier's College, Maitighar on Friday, 12 August 2016

For general FAQ's you can drop a comment below.
For some specific questions related to the courses, go to the link below and write a comment to ask the moderator of SXC's page Ask Specific Questions
Read More

Wednesday, August 10, 2016

Playfair Cipher with a Debugging challenge!

comments 0 Blogger Comments

Note: This source code has an Error. If you want a completely correct code, you'll have to ask me in the comments. I was under the impression that repeated letters are replaced with padding character(say X), instead of being inserted, while coding this. Hence the code reflects this output. I never really got around to change the code and fix this so since you've got a starting hint to write code for this cipher, Take it as a fun exercise to correct that mistake. Your debugging skills are being tested! :D
I enlarged the page but the code was still spread out. You can click on any spot in the code and then use LEFT/RIGHT Arrow keys to see parts of the code that is not visible. Alternatively, you could also just tap once on the code and then scroll right with your finger if you are using a touchscreen device.
#include <iostream>
#include <string>
using namespace std;

class Playfair
{
 string keyword;
 string ukey; //unrepeated keyword
 string plain;
 string cipher;
 string generic="ABCDEFGHIKLMNOPQRSTUVWXYZ";
 char pftable[5][5]; // 5x5 matrix table
 public:
  void setKey(string keyword)
  {
   this->keyword = keyword;
   //Capitalize all characters and replace all j with i in keyword
   for(int i=0;i<(int)keyword.length();i++)
   {
       keyword[i]=toupper((char)keyword[i]);
       if(keyword[i]=='J'){keyword[i]='I';}
   }
   //find unrepeated characters in keyword
   int x=0,itrepeated=0;
   cout<<endl<<"Tracing the processes of playfair Cipher"<<endl;
   for(int i=0;i<(int)keyword.length();i++)
   {
    for(int j=0;j<i;j++)
    {
              if (keyword[i]==keyword[j])
              {
                  itrepeated++;
                  cout<<"Discard Repeated Character->";
              }
             }
             if (itrepeated==0)
             {
                 cout<<"Store Non-Repeated Character to ukey("<<x<<")-";
                 ukey+=keyword[i]; //Note to self: don't use ukey[x] index on this part since ukey is unallocated pointer
                 x++;
             }
             cout<<keyword[i]<<"--> obtained from keyword("<<i<<") "<<endl;
             itrepeated=0;
   }
   cout<<endl<<"Length of keyword("<<keyword<<") = "<<keyword.length()<<"; removing repetitions("<<ukey<<") = "<<ukey.length()<<endl;
   //Now its time to put this ukey in matrix form of 5x5
   //Inserting into matrix
            cout<<endl<<"Inserting unrepeated keyword into playfair table in matrix form 5x5::";
         //First inserting ukey[k]
         int a=-1,b=0;
         for(int i=0;i<(int)ukey.length();i++)
         {
             if(i%5==0){cout<<endl;b=0;a++;}
             pftable[a][b]=(char)ukey[i];
             cout<<pftable[a][b]<<"["<<a<<"]"<<"["<<b<<"]"<<" "; //JUST TRACING (Uncomment this line to see trace result)
             b++;
         }
         
         x=0;
         itrepeated=0;
   for(int i=0;i<(int)generic.length();i++)
   {
       for(int j=0;j<(int)ukey.length();j++)
       {
           if(generic[i]==(char)ukey[j])
           {
               itrepeated++;
               break;
           }
       }
       if(!itrepeated)
       {
           if(((int)ukey.length()+x)%5==0){cout<<endl;b=0;a++;}
           pftable[a][b]=(char)generic[i];
                 cout<<pftable[a][b]<<"["<<a<<"]"<<"["<<b<<"]"<<" ";// JUST TRACING (Uncomment this line to see trace result)
                 x++;
                 b++;
       }
             itrepeated=0;
   }
   
  
  //At this point, keyword is properly formatted into the 5x5 matrix
  }
  void setPlain(string plain)
  {
   this->plain = plain;
  }
  void setCipher(string cipher)
  {
   this->cipher = cipher;
  }
  int * MapThisLetter(char Char2m)
  {
   static int r[2];
   r[0]=0;
   r[1]=0;
   
      for(int i=0;i<5;i++){
          for(int j=0;j<5;j++){
            
              if(pftable[i][j]==Char2m){
                  cout<<pftable[i][j];
                  r[0]=i;
                  r[1]=j;
                  break;
                  }
          }
      }
  return r;
  }
  void encrypt()
  {
     int *position;
     bool flag=0;
     int indexx1;
     int indexy1;
     int indexx2;
     int indexy2;
     for(int i=0;i<(int)plain.length();i++)
   {
       plain[i]=toupper((char)plain[i]);
       if(plain[i]=='J'){plain[i]='I';}
   }
  cout<<endl<<endl<<"Now mapping each letter to its corresponding cipher character from the playfair table:"<<endl;
  for(int i=0;i<(int)plain.length();i++)
  {
      position=MapThisLetter(toupper((char)plain[i++]));
      indexx1=*(position);
      indexy1=*(position+1);
      cout<<"["<<indexx1<<","<<indexy1<<"] & ";
      if(((char)plain[i-1]==(char)plain[i]) || (i>=(int)plain.length() && (int)plain.length()%2!=0)){
              position=MapThisLetter('X');
               indexx2=*(position);
               indexy2=*(position+1);
               cout<<"["<<indexx2<<", "<<indexy2<<"]";
               flag=1;//Indicates (a letter has been replaced with X) OR (a position has been padded with X)
      }// breaks at last line if odd length plaintext is entered
      if(!flag){
          position=MapThisLetter(toupper((char)plain[i]));
          indexx2=*(position);
          indexy2=*(position+1);
          cout<<"["<<indexx2<<", "<<indexy2<<"]";
      }
      //at shis point we already have x1,y1 and x2,y2 available for two letters of plaintext at a time. 
      //now we apply certain conditional comparisions
      if(indexx1==indexx2){
      //if x1==x2 i.e. when horizontal match then right shift
      indexy1=(indexy1+1)%4;
      indexy2=(indexy2+1)%4;
      cout<<" maps to: "<< pftable[indexx1][indexy1]<<"["<<indexx1<<", "<<indexy1<<"] & "<< pftable[indexx2][indexy2]<<"["<<indexx2<<", "<<indexy2<<"] respectively"<<endl;
      }
      else if(indexy1==indexy2){
      //if y1==y2 i.e when vertical match then down shift
      indexx1=(indexx1+1)%4;
      indexx2=(indexx2+1)%4;
      cout<<" maps to: "<< pftable[indexx1][indexy1]<<"["<<indexx1<<", "<<indexy1<<"] & "<< pftable[indexx2][indexy2]<<"["<<indexx2<<", "<<indexy2<<"] respectively"<<endl;
      }
      else{
          //exchange x1 and x2 in boxes
          indexy1=indexy1+indexy2;
          indexy2=indexy1-indexy2;
          indexy1=indexy1-indexy2;
          cout<<" maps to: "<< pftable[indexx1][indexy1]<<"["<<indexx1<<", "<<indexy1<<"] & "<< pftable[indexx2][indexy2]<<"["<<indexx2<<", "<<indexy2<<"] respectively"<<endl;
          }
          cipher+=pftable[indexx1][indexy1];
          cipher+=pftable[indexx2][indexy2];
      if(flag){//this flag is TRUE IF (selected both string are same) or (odd End-of-line has been reached)
          if((char)plain[i-1]==(char)plain[i]){flag=0;}//reseting the flag to Not-END-of-Line IFF selected both letters are the same  
          if(flag){break;} //no resetting; break IF odd End-of-line is padded with character X at the last position
      }
  }
  
  }
  void decrypt()
  {
  int *position;
     bool flag=0;
     int indexx1;
     int indexy1;
     int indexx2;
     int indexy2;
  cout<<endl<<endl<<"Now mapping each letter to its corresponding cipher character from the playfair table:"<<endl;
  for(int i=0;i<(int)cipher.length();i++)
  {
      position=MapThisLetter(toupper((char)cipher[i++]));
      indexx1=*(position);
      indexy1=*(position+1);
      cout<<"["<<indexx1<<","<<indexy1<<"] & ";
      if(((char)cipher[i-1]==(char)cipher[i]) || (i>=(int)cipher.length() && (int)cipher.length()%2!=0)){
              position=MapThisLetter('X');
               indexx2=*(position);
               indexy2=*(position+1);
               cout<<"["<<indexx2<<", "<<indexy2<<"]";
               flag=1;//Indicates (a letter has been replaced with X) OR (a position has been padded with X)
      }// breaks at last line if odd length plaintext is entered
      if(!flag){
          position=MapThisLetter(toupper((char)cipher[i]));
          indexx2=*(position);
          indexy2=*(position+1);
          cout<<"["<<indexx2<<", "<<indexy2<<"]";
      }
      //at shis point we already have x1,y1 and x2,y2 available for two letters of plaintext at a time. 
      //now we apply certain conditional comparisions
      if(indexx1==indexx2){
      //if x1==x2 i.e. when horizontal match then LEFT shift
      indexy1=(indexy1-1)%4;
      indexy2=(indexy2-1)%4;
      cout<<" maps to: "<< pftable[indexx1][indexy1]<<"["<<indexx1<<", "<<indexy1<<"] & "<< pftable[indexx2][indexy2]<<"["<<indexx2<<", "<<indexy2<<"] respectively"<<endl;
      }
      else if(indexy1==indexy2){
      //if y1==y2 i.e when vertical match then UP shift
      indexx1=(indexx1-1)%4;
      indexx2=(indexx2-1)%4;
      cout<<" maps to: "<< pftable[indexx1][indexy1]<<"["<<indexx1<<", "<<indexy1<<"] & "<< pftable[indexx2][indexy2]<<"["<<indexx2<<", "<<indexy2<<"] respectively"<<endl;
      }
      else{
          //exchange x1 and x2 in boxes
          indexy1=indexy1+indexy2;
          indexy2=indexy1-indexy2;
          indexy1=indexy1-indexy2;
          cout<<" maps to: "<< pftable[indexx1][indexy1]<<"["<<indexx1<<", "<<indexy1<<"] & "<< pftable[indexx2][indexy2]<<"["<<indexx2<<", "<<indexy2<<"] respectively"<<endl;
          }
          plain+=pftable[indexx1][indexy1];
          plain+=pftable[indexx2][indexy2];
      if(flag){//this flag is TRUE IF (selected both string are same) or (odd End-of-line has been reached)
          if((char)cipher[i-1]==(char)cipher[i]){flag=0;}//reseting the flag to Not-END-of-Line IFF selected both letters are the same  
          if(flag){break;} //no resetting; break IF odd End-of-line is padded with character X at the last position
      }
  }
  
  }
 string getPlainText()
 {
  return plain;
 }
 string getCipherText()
 {
  return cipher;
 }
};

int main() 
{
 Playfair playfair;
 int choice=1;//just for testing first choice
 string plain,cipher,keyword,ukey;
 cout<<"Playfair:: Enter 1 for Encryption or, 2 for Decryption-";
 cin>>choice;
if(choice == 1)
 {
  /* encryption */
  cout<<"Enter keyword-";
  cin>>keyword;
  cout<<"Enter plain text-";
  cin>>plain;
  playfair.setKey(keyword);
  playfair.setPlain(plain);
  playfair.encrypt();
  cout<<endl<<"Finally, we have the Cipher text = "<<playfair.getCipherText()<<endl;
 }
 else if(choice == 2)
 {
  /* decryption */
  cout<<"Enter key-";
  cin>>keyword;
  cout<<"Enter cipher text-";
  cin>>cipher;
  playfair.setKey(keyword);
  playfair.setCipher(cipher);
     playfair.decrypt();
  cout<<endl<<"Finally, we have the Plain text = "<<playfair.getPlainText()<<endl;
 }
 return 0;
}

Try it yourself!
Note: I was under the impression that repeated letters are replaced with padding character(say X) while coding this. Hence the code reflects this output. I never really got around to change the code and fix this so please Take it as a fun exercise to correct that mistake. Your debugging skills are being tested! :D
Read More

Most read this week!