Posts

Capta Generator in c

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

Check given number is even or not in c

#include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("enter the no"); scanf("%d",&n); if(n%2==0) { printf("no is even"); } else { printf("no is odd"); } getch(); }

Switch-Case Example in C

#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(); }

Program to remove duplicate elements in an array in C

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; }

Program to find Second largest number in an array in c

#include"stdio.h" main() { int a[]={15,67,25,90,40}; int k; k=large_number(a); printf("%d ",k); } int large_number(int un[5]) { int big1,big2; int i; big1 = un[0]; for ( i=1;i if ( big1 < un[i] ) big1 = un[i]; if ( big1!=un[0] ) big2=un[0]; else big2=un[1]; for(i=1; i if (big1!=un[i] && big2 < un[i] ) big2=un[i]; return big2; }

Program to find largest number in an array in c

#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 { if(big=a[i]) } return big; }

Program to calculate string palindrome in c

#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; } }