Posts

Get Local time| Get International Time in Javascript | Get Local time in php | Get Time according to timezone in php | Get Time According to local timezone

Local Time/ International Time. Headache! The solution:- Use unix timestamp for converting time to local of international timezone for different places. Just save your time as unix timestamp. From Your Browser: with javascript const unixtime= new Date().getTime(); Save this timestamp for database. While printing on frontend just pass it into the Date class: const localTime= new Date(unixtime); From php script: $unixTime=time().'000';

Benefits of using CDN links in head tag

The main benefit is your website  loads faster as compared to attached local files in head tags. Suppose if the browser has opened a website that contains some CDN links. Then after you open another website that has the dependecy of same CDN links will be loaded faster. Peoples generally install js or put css files of bootstrap locally to ensure the availablity of these dependecy as CDN links are outsider dependecy. But if you use CDN links the performance can be increased.

Experience or Talent?

So let's talk about experience in programming. My famous line " Experience doesn't matter, but talent matters"  hmm..... So initially you start your mindset of programming from your college or after college when you start working in a  software company. And you start counting your experience by year or months. All the thing is you got experience whenever you start believing in yourself. And for believing in ourselves we require some evidence that we are doing good, we got knowledge of it and that is how experience speaks from yourself. But suppose that you and your friend started from same point and have same potential but you got some oberservations regarding knowledge. Now experience is same but knowledge is different. To improve this you can do some different things like helping your juniors or getting openions from senior members.  It will develop yourself from inside and you will feel motivated. So , time is precious utilizes it in such way that is gives you best...

Given a sentence, , print each word of the sentence in a new line.

#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() {     char *s,tmp;     int len,i;     s = malloc(1024 * sizeof(char));     scanf("%[^\n]", s);     s = realloc(s, strlen(s) + 1);     //Write your logic to print the tokens of the sentence here.         len=strlen(s);     for(i=0;i<len;i++){         tmp=s[i];         if(tmp==' '){     printf("\n");             continue; }         printf("%c",s[i]);             }     return 0; }

spiral like pattern program in c

#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() {     int n,i,j,boundry,num;     scanf("%d", &n); boundry=(n*2)-1;     for(i=0;i<boundry;i++){      for(j=0;j<boundry;j++){           if(i<j) num=i; else num=j;          if(num>=boundry-i) num=boundry-i-1;          if(num>=boundry-j-1) num=boundry-j-1;          printf("%d ",n-num);                //printf("sa");     }          printf("\n");     }         return 0; }

bitwise AND OR NOT operations between numbers c program

Image
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> //Complete the following function. void calculate_the_maximum(int n, int k) {   //Write your code here.     int a1=0,o1=0,xo1=0,tmp1,tmp2,tmp3;     int s[n+1],i,j;     for(i=0;i<n;i++){         s[i]=i+1;     }       for(i=0;i<n;i++){         for(j=i+1;j<n;j++){          if(o1<s[i]|s[j]){              tmp1=s[i]|s[j];              if(tmp1<k){                              o1=s[i]|s[j];                                      }                  ...

C program to reverse a string without using any string functions-asr

Image
#include <stdio.h> #include <conio.h> void main() { char *s; int len,i=0; clrscr(); printf("\nENTER A STRING: "); gets(s); while(1){ if(s[i]=='\0'){ len=i; break; }          i++; }        for(i=len;i>=0;i--){ printf("%c",*(s+i));        } getch(); }

c patterns level 2

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() {     int i,j,k=1,l=9,tmp;     for(i=1,k=1;i<=10;i++,k=k+2,l--){           tmp=l;         for(j=1;j<=19;j++){                     if(j<=k){                        if(j<=i) {                ++tmp;                ...

patterns programs in c

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() {     int i,j,k,l;     for(i=1;i<=9;i++){               for(j=1;j<=5;j++){                      if(i<6){if(j<6-i) printf("  ");             else printf("* ");         }         else{             if(j<=i-5) printf("  ");       ...

task : debug the prime number logic

#include <stdio.h> #include <math.h> void main(){   int x,n=0,i; scanf("%d",&x); for(i=0;i<(int)sqrt(x);i++){     if(x%i==0){     n=1;     break;     }     } if(n==1) printf("not"); else printf("PRIME"); }

reverse of given string worlds c program -asr

Image
#include <stdio.h> void main(){         int i=0,len,num=0,a[10],j,f,l;     char s[100];                 while(1){         s[i]=getchar();         if(s[i]=='\n'){                 len=i;           //get chatacters                 s[i]=' ';        //set last character as space             break;   //break if enter pressed         }                 i++;     }         for(i=0;i<len;i++){     if(s[i]==' '){         a[num]=i+1;     //detect the positions where space is present         num++;     }     }  ...

kite patterns in c

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() {     int i,j,k;     for(i=1;i<=6;i++){             for(j=1;j<=5;j++){         if(i==1||i==5) {                        if(j==3) printf("*");             else printf(" ");                     }            if(i==2||i==4||i==6) {...

beautiful stars pattern based on inputted number-asr

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> int main() {     char a[20],n[10]; int num[10],x=0; int i=0,big=1,j; while(1){ a[i]=getchar(); n[0]=a[i]; //assignt into n[0] otherwise will err...coz index start from 0 num[x]=atoi(n);    if(a[i]=='\n'){     break;    }  i++; x++; } big=num[0]; for(i=1;i<x;i++){       if(big<num[i])   {         big=num[i];      //finding big number from inp...

aaabb to32 ,aabbb to a2b3 convert in c-asr

Image
/******************************************************************************     Online C Compiler. Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> int main() {   char s[10],c[10];   int i=1,j,tmp[10];   int p[10];   static int x,num=0;   s[0]='*';   c[0]='*';   tmp[0]=0;  printf("\nEnter a string\n");  while(1){     s[i]=getchar(); //reads single characters until enter pressed      if(s[i]==s[i-1])    //checks the previous character matched or not      { x++; tmp[num]=x; //increment x as much as character matches the previous characters insert into tmp      }      else{ x=1...

a2b3 output aabbb c program and beautiful use of getchar() ,isdigit() ,atoi() functions and stdlib.h header file-asr

Image
a2b3 output aabbb c program Beautiful use of getchar() ,isdigit() ,atoi() functions and stdlib.h header file i noted in string comparison single quote used,while in initialization double quotes /******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> int main() {   char s[10],n[10],c[10];   int i=0,j,num=0;   int p[10];  while(1){     s[i]=getchar(); //reads single characters until enter pressed     if(isdigit(s[i]))    //checks the character is digit or not ...

largest elemet in array-asr

largest elemet in array C program /******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() { int i,n,a[20],max; printf("enter any number"); scanf("%d",&n); for(i=0;i<n;i++){     scanf("%d",&a[i]);   } max=a[0]; for(i=1;i<n;i++){ if(max<a[i]){    max=a[i]; }  } printf("%d",max);     return 0; }

fibonacci upto n-asr

/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() { int a=0,b=1,c=0,n;     printf("Enter n"); scanf("%d",&n); while(1){       c=a+b;      if(c>n){         break;     }     printf("%d ",c);     a=b;     b=c;   }     return 0; }

prime number using square root -asr

Image
prime number c program using square root function -asr #include <stdio.h> #include <conio.h> #include <math.h> void main(){      int i,n,r,a=0; clrscr(); printf("Enter number\n"); scanf("%d",&n); if(n%2==0||n%3==0||n%5==0||n%7==0)     {   r=1;   goto check;     } for(i=11,a=1;i<= (int)sqrt(n); i=i+2,a++)          {              if(n%i==0)                                 {                                   r=1;                                 break;                                 }       ...

C program to print square spiral number pattern - asr

Image
#include <stdio.h> #include <conio.h> void main(){ int i,j,a[10],n=3,big,k; clrscr(); printf("enter three numbers\n "); for(i=0;i<n;i++){ scanf("%d",&a[i]); }      printf("\n"); for(i=1;i<=5;i++)    {     for(j=1;j<=5;j++)       {        i>1&&i<5&&j>1&&j<5?i==3&&j==3?        printf("%d ",a[0]):        printf("%d ",a[1]):        printf("%d ",a[2]);       }    printf("\n"); } getch(); }   output:

Java The number

Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991.  It took 18 months to develop the first working version. This language was initially called “Oak,” but was renamed “Java” in 1995. primary motivation was the need for a platform-independent (that is, architecture-neutral) language that could be used to create software to be embedded in various consumer electronic devices, such as microwave ovens and remote controls Although it is possible to compile a C++ program for just about any type of CPU, to do so requires a full C++ compiler targeted for that CPU. The problem is that compilers are expensive and time-consuming to create This second force was, of course, the World Wide Web. Java enhanced and refined the object-oriented paradigm used by C++, added integrated support for multithreading, and provided a library that simplified Internet access An applet is a special kind of Java progra...