Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Saturday, 29 September 2018

I’ve searched a lot on Google how to do certain git actions, and this actually motivated me to write this post. This may not be so useful for a person who is a PRO in git, but I tried to list out all the git commands which will definitely benefit a newbie.





Here are the list of git commands which is going to get covered in this Post:


Clone
Stash Changes
List stashes
Apply stash
List branches
Create Branch
Commit
Push
Pull
Checkout Branch
Config
Ignore Filemode changes


Git Clone:
git clone [url]


Git clone with custom directory name:
git clone [url] [directory name]


Git Clone with password:
git clone https://username:password@xyz.com/abc/repository.git


Stash Changes:
git stash save
git stash save [stash name] 
This command stash changes with name

List all stashes:
git stash list


Apply a stash:
git stash pop
git stash apply


List branches:
git branch
Note:  The one which is highlighted is the current branch


Create Branch:
git branch [branch name]


Commit:
git commit -m “[ commit message]”


Push changes:
git push origin [branch name]


Pull changes:
git pull origin [branch name]


Checkout branch:
git fetch && git checkout [branch name]


Config:
git config –global user.name [name]
git config –global user.email [email address]


This command sets the author name and email address to be used with your commits.


Ignore File mode changes:
git config core.fileMode false

If you need or know some more essential git commands, mention it in comments. I am always open to learning. 

Useful Git Commands for developer

Friday, 10 April 2015

           A loop involves repeating some portion of the program either a specified number of times or until a condition is satisfied. This repetitive operation (loop) is achieved in C through a for, or while or do-while loop.



               The statements within the loop would keep getting executed till the condition being tested remains true. When the condition becomes false, the control is transferred to first statement that follows the body of the loop.
For loop:
Syntax:
for(initialization; testing; increment/decrement)
{
          //sequence of statements;
}
Example:
for(i=1;i<=5;i++)
{
          printf“\n%d”,i);
}
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
          clrscr();
int i,factorial=1,n;
printf(“\nEnter the Number to find the factorial”);
scanf(“%d”,&n); //getting the input
for(i=1;i<=n;i++)
{
factorial=factorial*i;
}
printf(“\nThe factorial of %d is %d ”,n,factorial); //Displaying the output
getch();
}
Aim of this program is to find the factorial of the given number.
Program Explanation:
Include header files
Using scanf get the input to find the factorial.
Using for loop find the factorial of the given number.
Display the ouput.
While loop:
Syntax:
while(test_expression)
{
//sequence of statements;
}
Example:
while(i<5>
{
printf(“%d”,i);
i++;
}
Example Program:
#include<stdio.h>
#include<conio.h>
void main()
{
         
clrscr();
int i=1,factorial=1,n;
printf(“\nEnter the Number to find the factorial”);
scanf(“%d”,&n); //getting the input
while(i<=n)
{
factorial=factorial*i;
i++;
}
printf(“\nThe factorial of %d is %d ”,n,factorial); //Displaying the output
getch();
}


Looping Statements in C

Saturday, 28 March 2015

Decision making statements simply make decisions on the execution of the program that which line has to be executed next.
Decision making statements are
  • Simple if
  • If else
  • If else if else
  • Nested if
  • If else ladder

Simple if:
Syntax:
if(expression)
{
//true block;
}
Example Program:
#include<stdio.h>
void main()
{
int number=10;
clrscr();
if(number%2==0)
printf(“\n The given number is an Even number”);
getch();
}
Aim of this program is to find whether the given number is an even number.
Key idea: If the number is even, then it will definitely be divisible by 2. Whenever even number is divided by 2, then it will give the remainder as 0(zero).
To be known: if syntax, modulus operator(give the remainder)  
Program Explanation:
Include header file <stdio.h> for input output operations.
Declare the variable and initialize it to any number (I consider it as 10)
clrscr() – Clears the previous output from output screen
if(number%2==0)-checks whether the given number is divisible by 2
printf()-prints the statement if and only if the condition is true.
getch()-get character-->used to display output.
If  - else:
Syntax:
if(expression)
{
//true block;
}
else
{
//false block;
}
Example Program:
#include<stdio.h>
void main()
{
int number=10;
clrscr();
if(number%2==0)
printf(“\n The given number is an Even number”);
else
printf(“\n The given number is an odd number”);
getch();
}
Aim of this program is to find whether the given number is an even number or odd number.
Key idea: If the number is even, then it will definitely be divisible by 2. Whenever even number is divided by 2, then it will give the remainder as 0(zero).Otherwise it must be odd number.
To be known: if - else syntax, modulus operator(give the remainder)  
Program Explanation:
Include header file <stdio.h> for input output operations.
Declare the variable and initialize it to any number (I consider it as 10)
clrscr() – Clears the previous output from output screen
if(number%2==0)-checks whether the given number is divisible by 2
printf()-prints the statement if and only if the condition is true.
else – condition in if() is not true
 printf()-prints the statement if and only if the condition is false
getch()-get character-->used to display output.
 If - else if - else:
Syntax:
if(expression)
{
//true block1;
}
else if(expression)
{
//true block2;
}
else
{
//false block;
}
Example Program:
#include<stdio.h>
void main()
{
int number=10;
clrscr();
if(number>0)
printf(“\n The given number is Positive”);
else if(number<0)
printf(“\n The given number is Negative”);
else
printf("\n The given number is Zero");
getch();
}
Aim of this program is to find whether the given number is an positive or negative number.
Key idea
  • If the number is positive, then it will be greater than 0(zero).
  • If the number is negative, then it will be less than 0(zero).
  • Otherwise it must be 0(zero).

To be known: if - else if- else syntax, operators 
Program Explanation:
Include header file <stdio.h> for input output operations.
Declare the variable and initialize it to any number (I consider it as 10)
clrscr() – Clears the previous output from output screen
if(number>0) – checks whether the given number is greater than 0(zero)
printf() – prints the statement if and only if the condition is true.
else if(number<0) – checks whether the number is less than 0(zero)-->executes only if(number>0) evaluates false
else – condition in both if() and else if() is false
 printf() – prints the statement if and only if both the expressions evaluates false
getch() – get character-->used to display output.



Decision making statements in C

 
KayalSpot © 2015 - Designed by Templateism.com