-->

March 2014

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;
}
}
#include "stdio.h"
main()
{
int n;
printf("Enter the number range:");
scanf("%d",&n);
fibo(n);
}
int fibo(int n)
{
int i=0,j=1,k=2,r,f;
printf("%d %d ", i,j);
while(k{
f=i+j;
i=j;
j=f;
printf(" %d",j);
k++;
}
}
#include"stdio.h"
main()
{
int x,n;
printf("Enter a number :");
scanf("%d",&n);
x=bit_count(n);
printf("%d ",x);
}
int bit_count(int n)
{
int c=0;
while(n>0)
{
c++;
n=n&n-1;
}
return c;
}
#include  
main()
{
int x,n;
printf("Enter monthely expenditure :");
scanf("%d",&n);
x=daily_exp(n);
printf("%d ",x);
}
int daily_exp(int n)
{
int c=0;
while(n>0)
{
c++;
n=n-30;
}
return c;
}
#include

int main()
{
int x;
int a,b;
printf("Enter any two numbers :");
scanf("%d%d",&a,&b);
x=add(a,b);
printf("%d ",x);
}
int add(int a,int b)
{
while(a>0)
{
b++;
a--;
}
return b;
}
#include
#include
main()
{
int n,x;
printf("Enter a number:");
scanf("%d",&n);
x=palendrome(n);
if(x==n)
printf("Palendrome ");
else
printf("Not palendrome ");
}
int palendrome(int num)
{
int r=0;
while(num>0)
{
r=r* 10 + num%10;
num=num/10;
}
return r;
}
#include
main()
{
int x,n;
printf("Enter a number :");
scanf("%d",&n);
prime_factors(n);
}
int prime_factors(int n)
{
int i=1,k;
while(i<=n)
{
if(n%i==0)
{
k=check_prime(i);
if(k!=0)
printf("%d ",k);
}
i++;
}
}
int check_prime(int n)
{
int i=1;
int c=0;
while(i<=n)
{
if(n%i==0)
c++;
i++;
}
if(c==2)
return n;
else
return 0;
}
#include
#include
main()
{
int x,n;
printf("Enter a number :");
scanf("%d",&n);
x=strong(n);
if(x==n)
printf("Strong");
else
printf("Not strong");
}
int strong(int n)
{
int s=0,r,f;
while(n>0)
{
r=n%10;
f=fact(r);
s=s+f;
n=n/10;
}
return s;
}
int fact(int n)
{
int f=1;
while(n>0)
{
f=f*n;
n--;
}
return f;
}
#include

main()
{
int x,n;
printf("Enter a number :");
scanf("%d",&n);
x=reverse(n);
printf("%d",x);
}
int reverse(int n)
{
int s=0;
while(n>0)
{
s=s *10 + n%10;
n=n/10;
}

}
#include
#include
main()
{
int x,n;
printf("Enter a number :");
scanf("%d",&n);
x=sum_digit(n);
printf("%d",x);
}
int sum_digit(int n)
{
int s=0;
while(n>0)
{
s=s + n%10;
n=n/10;
}
return s;
}
#include 
 
int 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
#include
void main()
{
int i;
clrscr();
for(i=65;i<=90;i++)
printf("\n ascii code=%d and acscii value= %c",i,i);
getch();
}
#include
#include
#define pi 3.14
float area=0;
void cir_area(int);
void main()
{
int r;
clrscr();
printf("enter the r");
scanf("%d",&r);
cir_area(r);
printf("%f",area);
getch();
}
void cir_area(int r)
{
//float res;
area=pi*r*r;
//printf("%f",res);
}

#include<stdio.h>
 #include<conio.h>
 void main()
 {

 int i=2,n;
clrscr();
 printf("enter the  num    ");
 scanf("%d",&amp;n);
 while(i&lt;=n/2)
 {
 if(n%i==0)
 {
 printf("num is not prim");
 getch();
 exit(0);
 }
 i++;
 }

 printf("num is prim");
 getch();
 }
# include
# include
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}



*
**
***
****
*****
#include
#include
void main()
{
int n,a,m,i;
clrscr();
for(i=1;i<=10000;i++)
{
//printf("enter a no");
//scanf("%d",&n);
int sum=0;
a=i;
while(a!=0)
{
m=a%10;
a=a/10;
sum=sum+(m*m*m);
}
if(sum==i)
{
printf("%d\t ",i);
}
#include<stdio.h>
main( )
{
    int F1=0, F2=1, F3, limit;
    printf( " Series up to: " );
    scanf( "%d", &limit );
    if( limit >= 2 )
    {
        printf( "Fibonacci series is:\n" );
        printf( "%d, %d ", F1, F2 );
        F3 = F1 + F2;
        while( F3 <= limit )
        {
            printf( ", %d", F3 );
            F1 = F2;
            F2 = F3;
            F3 = F1 + F2;
        }/* End of while */
    }/* End of if */
}/* End of main( ) */
#include<stdio.h>
main( )
{
    int n,value;
    printf( "Enter the number : ");
    scanf( "%d", &n );
    if ( n < 0 )
        printf( "No factorial of negative number\n");
    else
        if ( n==0 )
            printf( "Factorial of zero is 1\n" );
        else
        {
            value = factorial( n ); /* Function for factorial of number */
            printf( "Factorial of %d = %d\n", n, value );
        }
}/*End of main()*/
factorial( int k )
{
    int fact =1;
    if ( k > 1 )
        fact = k * factorial( k-1 );  /* Recursive function call */
    return ( fact );
}

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...