Skip to content

Instantly share code, notes, and snippets.

View cynx's full-sized avatar
👓
blow

cynx cynx

👓
blow
View GitHub Profile
@cynx
cynx / _layout.cshtml
Created August 17, 2015 09:22
_layout.cshtml file for the JQUERY DATATABLES 1.10+ AND ASP.NET MVC 5 SERVER SIDE INTEGRATION
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - echosteg</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@cynx
cynx / getch_ungetch_example
Last active August 17, 2019 22:25
C program to illustrate use of getch() and ungetch()
#include <stdio.h>
#define BUFSIZE 100
int getch(void);
void ungetch(int c);
int buf[BUFSIZE]; /* buffer for ungetch */
int bufp = 0; /* next free position in buf */
@cynx
cynx / RightRotate
Created June 17, 2014 13:35
C function to rotate right
unsigned rightrot(unsigned x, unsigned n)
{
while (n > 0) {
if ((x & 1) == 1)
x = (x >> 1) | ~(~0U >> 1);
else
x = (x >> 1);
n--;
}
return x;
@cynx
cynx / BitCount
Created June 12, 2014 02:58
Count number of bits
int bitcount(unsigned x)
{
int b;
for(b = 0;x != 0;x &= x-1)
++b;
return b;
}
@cynx
cynx / Setbits
Created June 11, 2014 10:27
C program that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged.
#include <stdio.h>
unsigned setbits(unsigned x, int p, int n, unsigned y);
int main()
{
printf("%d", setbits(17, 4, 3, 13));
return 0;
}
unsigned setbits(unsigned x, int p, int n, unsigned y)
{
@cynx
cynx / Extract Binary digits
Created June 11, 2014 02:43
C function to extract n bits from p position of number x
#include <stdio.h>
unsigned getbits(unsigned x,int p,int n);
int main()
{
printf("%d",getbits(5, 4, 3));
return 0;
}
@cynx
cynx / String concatenate
Created June 10, 2014 02:54
C function to concatenate string
void strct(char s[],char t[]);
int main()
{
char s[7] = "mehul ";
char t[6] = "dhara";
strct(s,t);
printf("%s",s);
return 0;
@cynx
cynx / Lower Case
Created June 10, 2014 02:21
C function to convert string to lower case
/* convert C to lower case
int lcase (int c)
{
if (c >= 'A' && C <= 'Z')
retunr c + 'a' - 'A';
else
return c;
}
@cynx
cynx / Binary Decimal Conversion
Created June 9, 2014 17:55
C program to covert 'Decimal to Binary' and 'Binary to Decimal'
/* C programming source code to convert either binary to decimal or decimal to binary according to data entered by user. */
/* From http://www.programiz.com/ */
#include <stdio.h>
#include <math.h>
int binary_decimal(int n);
int decimal_binary(int n);
int main()
{
int n;
@cynx
cynx / Digit Count
Created June 9, 2014 17:16
C Program to count occurance of digits and white space and others
//to count occurance of digits and white space and others
#include <stdio.h>
int main()
{
int i,c,nwhites,nothers;
int ndigits[10];
c=nwhites=nothers=0;