THIS PROGRAM IS not yet complete the only problem is when the program calls for the find it process..it does not work perfectly i don't know why..but when i separate it its working..please help me with this..
this is how it looks separated from the optional program:
#include<stdio.h>
#include<conio.h>
int find[15];
void main()
{int target,ca,ga,da,ha,ja,ia,wa,fa,found;
clrscr();
for(ca=1;ca<16;ca++)
{printf("Input value%d:",ca);
scanf("%d",&find[ca]);ga=1;
for(ga=1;ga<ca;ga++)
{if(find[ca]==find[ga])
{printf("The number already exists!\n");
ca=ca-1;break;}}}
for(da=0;da<3;da++)
{ga=1;
printf("\nInput number to be find:");
scanf("%d",&target);
if(target==find[ga]||target==find[ga+1]||target==find[ga+2]||
target==find[ga+3]||target==find[ga+4]||target==find[ga+5]||
target==find[ga+6]||target==find[ga+7]||target==find[ga+8]||
target==find[ga+9]||target==find[ga+10]||target==find[ga+11]||
target==find[ga+12]||target==find[ga+13]||target==find[ga+14])
{printf("Output:\n");
printf("\tThe number is existing.");
}
else
{printf("Output:\n\t");
for(fa=1;ha!=0;fa++)
{ha=target-fa;
if(ha==find[ga]||ha==find[ga+1]||ha==find[ga+2]||
ha==find[ga+3]||ha==find[ga+4]||ha==find[ga+4]||ha==find[ga+5]||ha==find[ga+6]
||ha==find[ga+7]||ha==find[ga+8]||ha==find[ga+9]||ha==find[ga+10]||ha==find[ga+11]
||ha==find[ga+12]||ha==find[ga+13]||ha==find[ga+14])
{printf("%d",ha);}
ha=wa;ha=target+fa;
ha=target+fa;
if(ha==find[ga]||ha==find[ga+1]||ha==find[ga+2]||
ha==find[ga+3]||ha==find[ga+4]||ha==find[ga+4]||ha==find[ga+5]||ha==find[ga+6]
||ha==find[ga+7]||ha==find[ga+8]||ha==find[ga+9]||ha==find[ga+10]||ha==find[ga+11]
||ha==find[ga+12]||ha==find[ga+13]||ha==find[ga+14])
{printf("\t%d",ha);break;}
ha=target-fa;
if(wa==find[ga]||wa==find[ga+1]||wa==find[ga+2]||
wa==find[ga+3]||wa==find[ga+4]||wa==find[ga+5]||wa==find[ga+6]
||wa==find[ga+7]||wa==find[ga+8]||wa==find[ga+9]||wa==find[ga+10]||wa==find[ga+11]
||wa==find[ga+12]||wa==find[ga+13]||wa==find[ga+14]||ha==find[ga]||ha==find[ga+1]||ha==find[ga+2]||
ha==find[ga+3]||ha==find[ga+4]||ha==find[ga+5]||ha==find[ga+6]
||ha==find[ga+7]||ha==find[ga+8]||ha==find[ga+9]||ha==find[ga+10]||ha==find[ga+11]
||ha==find[ga+12]||ha==find[ga+13]||ha==find[ga+14])
{break;}}}}
getch();
}
this is how the main program looks like:#include<process.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
longest_word();alphabetical_order();text_messaging();
multiplication_table();find_it();supply_me();
bantumi();tic_tac_toe();guessing_game();
char a[]="threesome",b[]="casestudy",answer,
c[10],d[10],e,f,g,h,i,j,k,l,m,n,o,p;
int aa=0,bb,cc,dd,ee,ff,gg,hh,ii[11][11],
jj,kk,ll,mm,nn,oo,pp,qq,rr,target,find[15],found,ca,ga,da,ha,ja,wa,fa;
void main()
{clrscr();
do{printf("\nUsername:");
gets(c);
printf("Password:");
gets(d);
if(strcmp(a,c)==0&&strcmp(b,d)==0)
break;
else if(aa==2)
printf("System halted!");
else
printf("Invalid Username/Password");
aa++;}while(aa<3&&aa!=0);
if(aa<3)
{do
{clrscr();
printf("Main Menu");
printf("\n---------");
printf("\n[S]tring\n[A]rray\n[G]ames\n[E]xit\n");
printf("Enter your choice:");
scanf("\n");
scanf("%c",&e);
if(e=='S'||e=='s')
{clrscr();
printf("String Menu\n___________");
printf("\n[L]ongest Word\n[A]lphabetical Order");
printf("\n[T]ext Messaging\n[R]eturn to Main\n");
printf("Enter your choice:");
scanf("\n");
scanf("%c",&f);
if(f=='L'||f=='l')
gg=longest_word();
else if(f=='A'||f=='a')
gg=alphabetical_order();
else if(f=='T'||f=='t')
gg=text_messaging();
else if(f=='R'||f=='r')
gg=1;
else
{printf("INVALID!");break;}}
else if(e=='A'||e=='a')
{clrscr();
printf("Array Menu\n-----------");
printf("\n[M]ultiplication Table\n[S]upply Me\n");
printf("[F]ind It\n[R]eturn to Main\n");
printf("Enter your choice:");
scanf("\n");scanf("%c",&g);
if(g=='M'||g=='m')
gg=multiplication_table();
else if(g=='S'||g=='s')
gg=supply_me();
else if(g=='F'||g=='f')
{clrscr();
for(ca=1;ca<16;ca++)
{printf("Input value%d:",ca);
scanf("\n");
scanf("%d",&find[ca]);
scanf("\n");ga=1;
for(ga=1;ga<ca;ga++)
{if(find[ca]==find[ga])
{printf("The number already exists!\n");
ca=ca-1;break;}}}
for(da=0;da<3;da++)
{ga=1;
printf("\nInput number to be find:");
scanf("\n");scanf("%d",&target);
if(target==find[ga]||target==find[ga+1]||target==find[ga+2]||
target==find[ga+3]||target==find[ga+4]||target==find[ga+5]||
target==find[ga+6]||target==find[ga+7]||target==find[ga+8]||
target==find[ga+9]||target==find[ga+10]||target==find[ga+11]||
target==find[ga+12]||target==find[ga+13]||target==find[ga+14])
{printf("Output:\n");
printf("\tThe number is existing.");
}
else
{printf("Output:\n\t");
for(fa=1;ha!=0;fa++)
{ha=target-fa;
if(ha==find[ga]||ha==find[ga+1]||ha==find[ga+2]||
ha==find[ga+3]||ha==find[ga+4]||ha==find[ga+4]||ha==find[ga+5]||ha==find[ga+6]
||ha==find[ga+7]||ha==find[ga+8]||ha==find[ga+9]||ha==find[ga+10]||ha==find[ga+11]
||ha==find[ga+12]||ha==find[ga+13]||ha==find[ga+14])
{printf("%d",ha);}
ha=wa;ha=target+fa;
ha=target+fa;
if(ha==find[ga]||ha==find[ga+1]||ha==find[ga+2]||
ha==find[ga+3]||ha==find[ga+4]||ha==find[ga+4]||ha==find[ga+5]||ha==find[ga+6]
||ha==find[ga+7]||ha==find[ga+8]||ha==find[ga+9]||ha==find[ga+10]||ha==find[ga+11]
||ha==find[ga+12]||ha==find[ga+13]||ha==find[ga+14])
{printf("\t%d",ha);break;}
ha=target-fa;
if(wa==find[ga]||wa==find[ga+1]||wa==find[ga+2]||
wa==find[ga+3]||wa==find[ga+4]||wa==find[ga+5]||wa==find[ga+6]
||wa==find[ga+7]||wa==find[ga+8]||wa==find[ga+9]||wa==find[ga+10]||wa==find[ga+11]
||wa==find[ga+12]||wa==find[ga+13]||wa==find[ga+14]||ha==find[ga]||ha==find[ga+1]||ha==find[ga+2]||
ha==find[ga+3]||ha==find[ga+4]||ha==find[ga+5]||ha==find[ga+6]
||ha==find[ga+7]||ha==find[ga+8]||ha==find[ga+9]||ha==find[ga+10]||ha==find[ga+11]
||ha==find[ga+12]||ha==find[ga+13]||ha==find[ga+14])
{break;}}}}
printf("\nPress 1 to try another program?");
scanf("%d",&hh);}
else if(g=='R'||g=='r')
g=1;
else
{printf("INVALID!");break;}}
else if(e=='G'||e=='g')
{clrscr();
printf("Game Menu\n---------");
printf("\nantumi\n[T]ic-tac-toe\n[G]uessing Game\n[R]eturn to Main\n");
printf("Enter your choice:");
scanf("\n");
scanf("%c",&h);
if(h=='B'||h=='b')
gg=bantumi();
else if(h=='T'||h=='t')
gg=tic_tac_toe();
else if(h=='G'||h=='g')
gg=guessing_game();
else if(h=='R'||h=='r')
gg=1;
else
{printf("INVALID!");break;}}
else break;
}while(gg==1);
}getch();
}
longest_word()
{clrscr();printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
alphabetical_order()
{clrscr();printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
text_messaging()
{clrscr();printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
multiplication_table()
{clrscr();
for(int kk=1;kk<11;kk++)
{int jj=0;
for(jj=1;jj<11;jj++)
{
ii[kk][jj]=jj*kk;
if(ii[kk][jj]>=10)
printf(" %d",ii[kk][jj]);
else
printf(" %d",ii[kk][jj]);
}printf("\n");
}printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
supply_me()
{clrscr();
printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
bantumi()
{clrscr();printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
tic_tac_toe()
{clrscr();printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}
guessing_game()
{clrscr();printf("\nPress 1 to try another program?");
scanf("%d",&hh);
return(hh);}