-->

My Blog

Latest blog
EXAMPLE : PROGRAM TO GENERATE CAPTCHA IN C  
 
 
 This code are use to generate random captcha using c graphics. 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<stdlib.h>
#include<dos.h>
#include<graphics.h>
 
main()
{
   int i = 0, key, num, midx, gd = DETECT, gm;
   char a[10];
 
   initgraph(&gd,&gm,"C:\\TC\\BGI");
 
   midx = getmaxx()/2;
 
   settextstyle(SCRIPT_FONT,HORIZ_DIR,5);
   settextjustify(CENTER_TEXT,CENTER_TEXT);
   setcolor(GREEN);
   outtextxy(midx,20,"CAPTCHA");
   settextstyle(SCRIPT_FONT,HORIZ_DIR,2);
   outtextxy(midx,125,"Press any key to change the generated random code \"captcha\"");
   outtextxy(midx,150,"Press escape key to exit...");
 
   setcolor(WHITE);
   setviewport(100,200,600,400,1);
   setcolor(RED);
   randomize();
 
   while(1)
   {
      while(i<6)
      {
         num = random(3);
 
         if ( num == 0 )
            a[i] = 65 + random(26);     /* 65 is the ASCII value of A */
         else if ( num == 1)
            a[i] = 97 + random(26);     /* 97 is the ASCII value of a */
         else
            a[i] = 48 + random(10);     /* 48 is the ASCII value of 0 */
         i++;
      }
      a[i] = '\0';
      outtextxy(210,100,a);
      key = getch();
 
      if( key == 27 )                     /* escape key*/
         exit(0);
      clearviewport();
      i = 0;
   }
}

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int n;
  6. clrscr();
  7. printf("enter the no");
  8. scanf("%d",&n);
  9. if(n%2==0)
  10. {
  11. printf("no is even");
  12. }
  13. else
  14. {
  15. printf("no is odd");
  16. }
  17. getch();
  18. }

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
char op,choice;
clrscr();
do
{
printf("enter two no");
scanf("%d%d",&a,&b);
printf("enter the operator");
flushall();
scanf("%c",&op);
switch(op)
{
case '+':
c=a+b;
printf("%d",c);
break;
case '-':
c=a-b;
printf("%d",c);
break;
case '*':
c=a*b;
printf("%d",c);
break;
case '/':
c=a/b;
printf("%d",c);
break;
default:
printf("wrong operator");
}
printf("do u want to coninue y/n:");
flushall();
scanf("%c",&choice);
}
while(choice=='y');
getch();
}


main()
{
int i,k;
int x[10]={5,7,2,8,9,3,3,6,7,20};
k=remove_duplicate(x);
for(i=0;i  printf(" %d",x[i]);
}
}
int remove_duplicate(int p[10])
{
int size=10,i,j,k;
for(i=0;i

{
for(j=0;j 

{
if(i==j)
{
continue;
}
else
if(*(p+i)==*(p+j))
{
k=j;
size--;
while(k &lt; size)
{
*(p+k)=*(p+k+1);
k++;
}
j=0;
}
}
}
return size;
}

  1. #include"stdio.h"
  2. main()
  3. {
  4. int a[]={15,67,25,90,40};
  5. int k;
  6. k=large_number(a);
  7. printf("%d ",k);
  8. }
  9. int large_number(int un[5])
  10. {
  11. int big1,big2;
  12. int i;
  13. big1 = un[0];
  14. for ( i=1;i<5 font="" i="">
  15. if ( big1 < un[i] )
  16. big1 = un[i];
  17. if ( big1!=un[0] )
  18. big2=un[0];
  19. else
  20. big2=un[1];
  21. for(i=1; i<5 font="" i="">
  22. if (big1!=un[i] && big2 < un[i] )
  23. big2=un[i];
  24. return big2;
  25. }
#include"stdio.h"
main()
{
int a[]={15,67,25,90,40};
int k;
k=large_number(a);
printf("%d ",k);
}
int large_number(int a[5])
{
int i,big;
big=a[0];
for(i=1;i<5 p="">{
if(big=a[i])
}
return big;
}
#include "stdio.h"
#include"string.h"
main()
{
char x[100],y[100];
printf("Enter a string :");
scanf("%s",x);
strcpy(y,x);
check_palindrome(x);
if(strcmp(x,y)==0)
printf("Palindrome");
else
printf("Not Palindrome");
}
int check_palindrome(char *x)
{
int len=strlen(x);
int i;
char temp;
for(i=0;i{
temp=x[i];
x[i]=x[len-i-1];
x[len-i-1]=temp;
}
}

Feel Free To Write Imam Uddin

Get In Touch

Drop me a line, or give me a heads up if you have a plan for your Online Business! Simply write to me or find me in google. Also can contact with me on all popular social meadia by @imamuddinwp . I'd love to hear from you! My inbox is always open! 😎

Get In Touch!

NextGen Digital Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...