Skip to content

Instantly share code, notes, and snippets.

View SohanChy's full-sized avatar

Sohan Chowdhury SohanChy

View GitHub Profile
@SohanChy
SohanChy / fibonacci.c
Created July 7, 2015 06:58
Simple Fibonacci printing using function
#include <stdio.h>
#include <stdlib.h>
void fibo(int end);
int main()
{
fibo (10);
return 0;
}
@SohanChy
SohanChy / prime.c
Created July 26, 2015 14:10
Prime Checking
#include <stdio.h>
int main()
{
int x,isprime=1;
scanf("%d",&x);
if(x==1 || x==2)
{
printf("Prime Number %d",x);
@SohanChy
SohanChy / primeFactorialRecursion.c
Created July 26, 2015 16:59
Prime Factorial of Any Number entered using recursion
#include <stdio.h>
void pfact(int n);
int main()
{
pfact(147);
return 0;
}
@SohanChy
SohanChy / toroman.c
Created July 26, 2015 17:01
Convert any given year to Roman Numerals in C
#include <stdio.h>
void toroman(int y);
int main()
{
toroman(1525);
return 0;
}
@SohanChy
SohanChy / fibonacci-recursion.c
Created July 26, 2015 17:40
Printf n number of Fibonacci numbers using recursion in C
#include <stdio.h>
void fibo(int n, int first, int second);
int main()
{
int first = 0, second = 1;
fibo(10, first, second);
return 0;
@SohanChy
SohanChy / evaluate-sinex.c
Created July 26, 2015 18:29
Evaluate value of sine(x) in C
#include <stdio.h>
#include <math.h>
float sine(int deg);
int fact(int n);
int main()
{
int x = 90;
printf(" %f ",sine(x));
@SohanChy
SohanChy / force-show-pdf.php
Created July 28, 2015 16:35
Try to show a PDF instead of download.
<?php
$file = './path/to/the.pdf';
$filename = 'Custom file name for the.pdf'; /* Note: Always use .pdf at the end. */
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@SohanChy
SohanChy / fact recur.c
Created August 8, 2015 05:51
Factorial in C using Recursion
#include<stdio.h>
// Video explanation in Bangla at
// https://youtu.be/c8LhCLnU5bc
int main()
{
int x = 3;
int result = factorial(x);
printf("Factorial of 3 = %d",result);
@SohanChy
SohanChy / remove spaces from string.c
Created August 8, 2015 20:51
Remove spaces from string
#include<stdio.h>
#include<string.h>
int main()
{
char xyz[] = "Hey, I have got LOTS of SPACEEEE";
char x[50];
int i=0,j=0;
for(i=0; j<= strlen(xyz);)
@SohanChy
SohanChy / bigmod.c
Last active August 29, 2015 11:09
NEED TO UNDERSTAND
#include <stdio.h>
int bigmod(int a, int p, int m)
{
int res = 1;
int x = a;
while(p) {
if(p&1) //odd
{
res =(long long) (res*x)%m;