Posts

Showing posts from April, 2017

Tricky Questions or puzzles in C Part 3

Thank You for the amazing response to the previous two posts on Tricky questions on C. In this post, we will again see some of the nice and interesting questions often asked in the interviews. 1) How to calculate the Factorial of the number without using Recursion and Loop? Calculating factorial is very simple using recursion or loop, but how to calculate factorial without using anything? Using the sterling´s approximation for the factorial , which is given by the formula n! = sqrt(2*pi*n)*pow((n/e),n)  Please note that this formula will not give the exact value of the factorial because it is just the approximation of the factorial. I understand that it is not a "Tricky" question but it depends on the knowledge of the person about this formula, so if somebody has seen the formula then only he can answer the question. This is the rough code for calculating the above (may not work with large numbers) int main { int a; float e,y,x,z; scanf("%d&q

GIT Notes for the Interview PART-3

My last post was all about git add, git commit, git pull, and git push. In this post, we will see what is remote-tracking branches and how to create them. You can create a local branch that will track the mentioned remote branch using the command below git checkout --track origin/testrepo This command will create one local branch name testrepo which is tracking remote branch name testrepo , here origin is the remote. If you want to create a branch with a different name you can use the below command git checkout -b newname origin/testrepo This will create a local branch name newname Please note that you can only use commands git pull git push when your branch is already tracking some remote branch, but if your branch is not created by using the above-mentioned commands, then you need to mention explicitly in the git push and git pull commands about the remote branch from where and to where you need to pull and push respectively. The new command

GIT Notes for the Interview PART-2

After the basics of GIT like cloning the repository, creating a branch in the previous post, now we will look at how to add files, commit and push your changes. Once you are done with writing your code or changes to existing code or module, you need to add files that you have changed into the staging area To check which files you need to add, write this command git status This command is used to check the current status of your local branch, which files are ready to be committed, and which files need to be added to the staging area for commit. You will see some files in Red color modified : folder/xyz/abc.cpp This file is not added to the staging area, so you need to add the files using the command git add folder/xyz/abc.cpp Once you are done with adding the file in the staging area, your file is ready for the commit. For commit use the following command git commit -m "Added condition for denominator not equal to zero in abc.cpp" here you can use -m and

GIT Basic Notes for the Interview PART-1

GIT is the most widely used Version control System by the developers across globe. The main functionality of GIT is tracking changes in file and makes it easy to coordinate the work between multiple people in the project It maintains a remote repository and the developer can create a local repository in the system, do his changes in the local repository and then push the changes to the remote repository. This makes the development process go smoothly with less hassle and issues. The first thing is to clone the remote repository on your system using the GIT clone command git clone username@host:path-to-repository You can also use git clone --recursive username@host:path-to-domain-repository  when you are cloning a project with sub-modules. Here --recursive parameter will cause sub-modules to be properly initialized and cloned. After you cloned a repository you can see all the dev files within the project. Now, to start developing the project you need to create one l