Thursday, August 27, 2009

Smokers Algorithem



#include<stdio.h>



#include<conio.h>



main()



{



static
char item[3][9]={"PAPER","TOBACCO","MATCHBOX"};



char ch;



int a,b,i;



clrscr();



printf("\n\n\t\tSMOKERS
ALGORITHM"
);



printf("\n\t\t~~~~~~~
~~~~~~~~~"
);



do



{



AB:



printf("\nSelect
the Two Item:"
);



printf("\n\t\tItemNo\tItem");



printf("\n\t\t 1\tPaper\n\t\t
2\tTobacco\n\t\t 3\tMatchbox"
);



printf("\n\tEnter
Two Itemno Supplied By Agent : "
);



scanf("%d%d",&a,&b);



a=a-1;



b=b-1;



if((a>2)(a<0)(b>2)(b<0)(a==b))



{



printf("\n\t\tInvalid
Input,Try Again.."
);



getch();



goto
AB;



}



printf("\n\tItems
Supplied By Agent : %s & %s"
,item[a],item[b]);



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



{



if((i!=a)&&(i!=b))



printf("\n\tSmoker
Already Have Item : %s"
,item[i]);



}



printf("\n\n\t\tDo
You Want To Continue (Y/y) : "
);



fflush(stdin);



scanf("%c",&ch);



}while((ch=='Y')(ch=='y'));



}


Click to Download Source Code
or
Copy and past in browser address bar

http://sites.google.com/site/senthilmcan/software-programs


No comments:

Post a Comment