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:  

Swapping of Two number

Image
C Program to Swapping of Two number #include<conio.h> #include<stdio.h> void main() {     int num1,num2,temp=0;     clrscr();     printf("Enter first number : ");     scanf("%d",&num1);     printf("Enter second number : ");     scanf("%d",&num2);     printf("\n\nValue of A: %d   and  Value of B: %d",num1,num2);     temp=num1;     num1=num2;     num2=temp;     printf("\n\n\n After swaping \n\n");     printf("Value of A: %d   and  Value of B: %d",num1,num2);     getch(); } out put

Swapping two number without 3rd variable

Image
C Program to Swapping two number without 3rd variable #include<conio.h> #include<stdio.h> void main() {     int num1,num2;     clrscr();     printf("Enter first number : ");     scanf("%d",&num1);     printf("Enter second number : ");     scanf("%d",&num2);     printf("\n\nValue of A: %d   and  Value of B: %d",num1,num2);     num1=num2+num1;     num2=num1-num2;     num1=num1-num2;     printf("\n\n\n After swaping \n\n");     printf("Value of A: %d   and  Value of B: %d",num1,num2);     getch(); } out put:

Print table of any number

Image
C Program to Print table of any number #include<conio.h> #include<stdio.h> void main() {     int n ,i;     clrscr();     printf("Enter Number for Table print: ");     scanf("%d",&n);     for(i=1;i<=10;i++)     {         printf("\n %d x %d = %d",n,i,n*i);     }     getch(); } out put :  

Add two integer numbers with user input

Program to add two integer numbers and give number at run-time #include<conio.h> #include<stdio.h> void main() { int number1, number 2; clrscr(); printf("Enter First Integer number : "); scanf("%d", &number1); printf("Enter Second Integer number : "); scanf("%d", &number2); printf( " Sum of %d and %d is %d" ,number1,number2,number1+number1); getch(); }

Addition of Two number.

Program to add two numbers #include<conio.h> #include<stdio.h> void main() { printf("Sum of Two number 5 and 8 are : " 5 + 8); getch(); }

User Input

Program to give in put through keyboard or Program to give input at run time #include<conio.h> #include<stdio.h> void main() { char name; clrscr(); printf("enter your name : "); scanf("%s ",& name); getch(); } OutPut enter your name : BRIJESH

Hello world

FIRST PROGRAM THE WORLD STARTS.. #include<conio.h> #include<stdio.h> void main() { printf("HELLO WORLD THIS IS MY FIRST PROGRAM"); getch(); } output: HELLO WORLD THIS IS MY FIRST PROGRAM

SKILL ROCKS TECH SECOND QUESTIONS ANSWER

Q2 find the greatest no. from an array having random numbers of 100 size, with out sorting. int biggest = ar[0]; for(i=0;i<100;i++) {          if(biggest <ar[i])          biggest=ar[i]; } cout<< " greatest no. of array :"<<ar[i];

SKILL ROCKS TECH THIRD QUESTION ANSWER

Q3 find the frequency of 1 to 9 from an array of size 100 having value 1 to 9 randomly arranged Conditions: 1. use only one loop. 2. do not use counters. 3. most efficiently  Answer suppose if array of 100 with random values between 1 to 9 were given then  simply answer is for(i=0;i<100;i++) {           count[ arr[i] ]++; // arr[i] is given array and count[] is frequency counter. } complete program is like this #include<conio.h> #include<iostream.h> #include<stdlib.h> void main() {     int arr[100],count[10],i,j;     clrscr();     for(i=0;i<20;i++)     {         arr[i]=random(10);     }     for(i=0;i<20; i++)     {         cout<<arr[i];         if(i%10==0)      ...

SKILL ROCKS TECH QUESTIONS

skillrocks technical interview question Q1 an array of 20 integer having digits 1 to 20 in random order, if we omit any one digit and replace it by zero find the number omitted. example |1|3|5|7|8|9|4|2|6|10|0|13|15|16|17|19|18|15|20|12|14| Q2 find the greatest no. from an array having random numbers of 100 size, with out sorting. Q3 find the frequency of 1 to 9 from an array of size 100 having value 1 to 9 randomly arranged Conditions: 1. use only one loop. 2. do not use counters. 3. most efficiently  Answer is waiting.....