My little achievement on Quora

Quora has given me a badge on my profile for most viewed writer in Social Psychology and Character & Personality.

It’s an achievement for me. The credits goes to this “Answer“. Though these are not so much upvotes, still matters to me a lot.

Have Fun.

What does “++a + ++a” really mean ?

Hi,

If a=1, then how ++a + ++a=6?

I had been asked these type of questions many times by my teachers, but as I remember they all gave me different explanations that is why I could not remember what the correct explanation is ;).

But now I found a genuine answer for it. Below is the explanation’s link, as I can’t  explain the concept better than Aparajita ji .

Click for Explanation

Thanks to her.

Enjoy, Keep Coding 🙂

 

Calendar in C

Hi,

I wrote the code for Calendar in C. It will tell you the name of the day of any date after Jan 1st, 1901.

It is really interesting, you should try on your own before looking at the code.

#include<stdio.h>
int main()
{
    int i,s=0,r,n,d,m,y,j,k,l,b=0,kn=0;
    printf("enter day : ");
    scanf("%d",&d);
    printf("enter month : ");
    scanf("%d",&m);
    printf("enter year : ");
    scanf("%d",&y);
    i=1901;
    j=1;
    k=1;
    l=2;
    while(1)
    {
        while(1)
        {
            while(1)
            {
                if(i==y && j==m && k==d)
                {
                    if(l==1)
                        printf("\nMonday\n");
                    if(l==2)
                        printf("\nTuesday\n");
                    if(l==3)
                        printf("\nWednesday\n");
                    if(l==4)
                        printf("\nThursday\n");
                    if(l==5)
                        printf("\nFriday\n");
                    if(l==6)
                        printf("\nSaturday\n");
                    if(l==7)
                        printf("\nSunday\n");
                    kn=1;
                    break;
                }

                l++;
                if(l==8)
                l=1;

                if((i%4==0 && i%100!=0) || i%400==0)
                {
                    if(j==2)
                    {
                        if(k==29)
                        {
                            k=1;
                            break;
                        }
                    }
                }
                else if(j==2)
                {
                    if(k==28)
                    {
                        k=1;
                        break;
                    }
                }
                if(j==4 || j==6 || j==9 || j==11)
                {
                    if(k==30)
                    {
                        k=1;
                        break;
                    }
                }
                else if(k==31)
                {
                    k=1;
                    break;
                }
                k++;
            }
            if(j==12)
            {
                j=1;
                break;
            }
            j++;

            if(kn==1)
                break;
        }
        i++;
        if(kn==1)
            break;
    }
    return 0;
}

For any clarification, contact me.

Enjoy, Keep Coding 🙂

Create Matrix of different elements using rand() function

Hi,

Once my friend came to me and ask for a problem, which is to be implemented in the C/C++.

The problem:
You have to create a matrix, input element in the matrix using rand() function, the condition is that all element should be different(no duplicate) in the matrix.

I sugest you to first try to implement yourself before checking the solution.

C code for the above problem:

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int t,n,m,a[100][100],r,temp[200]={0},i=0,j=0,k=0,l,cnt=0,ex=1,rl;
    srand ( time(NULL) );
    printf("enter size of the matrix : ");
    scanf("%d",&n);
    printf("enter maximum limit of random no. (should be greater than size*size) : ");
    scanf("%d",&rl);
    printf("\n");
    while(i<n)
    {
        j=0;ex=1;cnt=0;
        while(j<n)
        {
            ex=1;cnt=0;
            r=rand()%rl+1;
            while(ex)
            {
                for(l=0;l<k;l++)
                {
                    if(temp[l]==r)
                    {
                        cnt=1;
                        break;
                    }
                }

                if(cnt==0)
                    ex=0;
                if(cnt==1)
                {
                    r=rand()%rl+1;
                    cnt=0;
                }
            }
            temp[k++]=r;
            a[i][j]=r;
            j++;
        }

        i++;
    }

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            printf("%d      ",a[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Enjoy, Keep Coding 🙂

The Dictionary (Chrome Extension)

Hi, Please check my chrome extension “The Dictionary” that I made recently in JavaScript. Just select the word and click on the extension icon to get the meaning.

You can download The Dictionary extension in zip format from my github account. Also you can check for the instructions for how to install and how to use.

I will be happy to get the feedback. 🙂

Email – karandev43@gmail.com

 

Thank You.

C code to print India’s Map

#include<stdio.h>
int main()
{
int a,b,c;
int count;
count=1;
for (b=c=10;a=”- FIGURE?, UMKC,XYZHello Folks,\
TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
Hq!WFs XDt!” [b+++21]; )
for(; a– > 64 ; )
putchar ( ++c==’Z’ ? c = c/ 9:33^b&1);
return 0;
}

Image