Posts

Php Check is date or not

This Function check if the given string is date type or not!!. And Return True or false according to the result. function isDate($string ='') {         DateTime::createFromFormat('Y-m-d', $string) !== FALSE ?  return true  : return false; }

Ranibow design in c Language

Image
C Program to  Create rainbow #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int gdriver = DETECT,gmode; int x,y,i;     initgraph(&gdriver,&gmode,"C:\\Turboc3\\BGI");     x=getmaxx()/2;     y=getmaxy()/2;     for(i=30;i<200;i++)     {         delay(100);         setcolor(i/10);         arc(x,y,0,180,i-10);     } getch(); } Out put

Print stars in c

Image
C Program to  Print stars #include<conio.h> #include<stdio.h> void main() {         int i,j,l;         clrscr();         for(j=1;j<5;j++)         {             for(i=4;i>=j;i--)             printf(" ");             for(l=1;l<=2*j-1;l++)             printf("*");             printf("\n");         }         for(i=1;i<=6;i++)         {             for(j=0;j<=i;j++)             printf(" ");       ...

Circle in C graphics

Image
C Program to  Draw Circle  #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int midx, midy;    int radius = 100;    /* initialize graphics and local variables */    initgraph(&gdriver, &gmode, "C:\\turboc3\\bgi");    /* read result of initialization */    errorcode = graphresult();    if (errorcode != grOk)  /* an error occurred */    {       printf("Graphics error: %s\n", grapherrormsg(errorcode));       printf("Press any key to halt:");       getch();       exit(1); /* terminate with an error code */    }    midx = getmaxx() / 2;    midy = getmaxy() / 2; ...

Pattern of barfi in c

Image
C Program to create pattern #include<conio.h> #include<stdio.h> void main() {     int i,j,k;     clrscr();     for(i=0;i<=5;i++)     {         for(j=5;j>=i;j--)         printf("^");         for(k=1;k<=2*i;k++)         printf(" ");         for(j=5;j>=i;j--)         printf("^");         printf("\n");     }     for(i=1;i<=6;i++)     {         for(j=1;j<=i;j++)         printf("^");         for(k=11;k>=2*i;k--)         printf(" ");         for(j=1;j<=i;j++)   ...

C Program for Analog Clock Design

Image
C Program to  Create Analog clock #include<conio.h> #include<graphics.h> #include<math.h> #include<dos.h> #define WBC 5 //^watchbackcolor #define X 200 #define Y 200 void dial(int x, int y); void sechand(int timeminute); void minhand(int t) { int x1,y1; setlinestyle(0,0,3); x1= X+ (80 * cos(t*0.1047)); y1= Y+ (80 * sin(t*0.1047)); setcolor(BLACK); line( X, Y, x1, y1); setcolor(WBC+1); line( X, Y, X+ 80 * cos((t-1)*0.1047),Y+ 80 * sin((t-1)*0.1047)); circle(X,Y,4); } void sechand(int t) { int x1,y1; setlinestyle(0,0,3); x1= X+(100 * cos(t*0.1047)); y1= Y+(100 * sin(t*0.1047)); setcolor(RED); line(X, Y, x1, y1); setcolor(WBC+1); line(X, Y, X+ 100 * cos((t-1)*0.1047),Y+ 100 * sin((t-1)*0.1047)); circle(X,Y,4); } void dial(int x,int y) { int const size=200; setfillstyle(1,WBC); fillellipse(x,y,size,size); setfillstyle(1,WBC+1); fillellipse(x,y,size-20,size-20); outtextxy(x,y-(size-40),"12"); out...

C Program to check prime number

Image
C Program to  check prime number  #include<conio.h> #include<stdio.h> void main() {     int p,i;     clrscr();     printf("enter no. to check prime: ");     scanf("%d",&p);     for(i=2;i<p;i++)     if(p%i==0)     {         printf("%d is not a prime number ",p);         break;     }     if(i==p)     printf("%d is prime number",p);     getch(); } Explanation int p,i;       p and i are two variables of integer type ; printf() and scanf() are predefine functions use for read and write respectively. for(i=2;i<p;i++) for loop use to check prime number  count  if(p%i== 0) if p % i = 0 then it means 'p' has any common factor between 1 to p which means it is not a prime...

Perform looping with if statement.

Image
C Program to  create if loop #include<conio.h> #include<stdio.h> void main() {     int i,j,k,l=1;     clrscr();     i=1;     i1:     if(i<=5)     {         j=4;         j1:         if(j>=i)         {             printf(" ");             j--;             goto j1;         }         k=1;         k1:         if(k<=l)         {             printf("*");             k...

C Program Check even and odd input

Image
C Program  Check even and odd input #include<conio.h> #include<stdio.h> void main() {     int num1;     clrscr();     printf("Enter number : ");     scanf("%d",&num1);     if(num1%2==0)     printf("%d is Even number ",num1);     else     printf("%d is odd number ",num1);     getch(); } Output:

Find Factorial of any number

Image
C Program to Find Factorial of any number #include<conio.h> #include<stdio.h> void main() {     int number,fact,i;     clrscr();     printf("Enter Number : ");     scanf("%d",&number);     fact=1;     for(i=1;i<=number;i++)     {         fact=fact*i;     }     printf("factorial of %d is : %d",number,fact);     getch(); } Output: