-->
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; } }
#includeint main() { int a, b, x, y, t, gcd, lcm; printf("Enter two integers\n"); scanf("%d%d", &x, &y); a = x; b = y; while (b != 0) { t = b; b = a % b; a = t; } gcd = a; lcm = (x*y)/gcd; printf("Greatest common divisor of %d and %d = %d\n", x, y, gcd); printf("Least common multiple of %d and %d = %d\n", x, y, lcm); return 0; }
#include<stdio.h> #include<conio.h> void main() { int i=2,n; clrscr(); printf("enter the num "); scanf("%d",&n); while(i<=n/2) { if(n%i==0) { printf("num is not prim"); getch(); exit(0); } i++; } printf("num is prim"); getch(); }
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! 😎
I'm Social; Stay Connected!