This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Shift operators shift the bits in an integer variable by a specified | |
* number of positions. The << operator shifts bits to the left, and the >> | |
* operator shifts bits to the right. The syntax for these binary operators | |
* is x << n and x >> n | |
* Each operator shifts the bits in x by n positions in the specified | |
* direction. For a right shift, zeros are placed in the n high-order bits | |
* of the variable; for a left shift, zeros are placed in the n low-order | |
* bits of the variable. | |
* Here are a few examples: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Stack is a last in, first out (LIFO) abstract data type and data | |
* structure.It is characterized by three fundamental operations: push, | |
* pop and stack top. | |
* PUSH : The push operation adds a new item to the top of the stack, or | |
* initializes the stack if it is empty, but if the stack is full and | |
* does not contain more space to accept the given item it is considered | |
* as an Overflow state (It means that the stack is overloaded or no more | |
* space for new item). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Program to delete an element from an array | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int *array, size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Program to check the occurrences of a pattern in a text/string | |
* This program checks whether the pattern occur in the string | |
* or not, if yes at what positions and also print the text/string | |
* highlighting the occurrences | |
**/ | |
#include <stdio.h> | |
#include<string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A palindrome is a word, phrase, number or other sequence | |
* of units that can be read the same way in either direction | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
int main(void) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To find the factorial of a number | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int n, i, f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To check whether a number is prime or not | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int n, i, p = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Swapping without using a temporary variable in C | |
* (XOR) | |
**/ | |
#include<stdio.h> | |
int main(void) | |
{ | |
int a = 5; /* a = 0101 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Swapping without using a temporary variable in C | |
* (Multiplication & Division) | |
**/ | |
#include<stdio.h> | |
int main(void) | |
{ | |
int a = 5, b = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Binary Search locates the position of an item in a sorted list. | |
* | |
* Divide : It works by dividing the list into two halves and | |
* comparing the input value to be searched with the | |
* middle element of the list. | |
* | |
* Conquer : If the input value is equal to the mid value, search | |
* is successful. If greater, call binary search only | |
* on the greater sub-array of the sorted list and if | |
* lesser, call binary search on the lesser sub-array. |
NewerOlder