Skip to content

Instantly share code, notes, and snippets.

View GReturn's full-sized avatar
🦀
Become crab.

Lindrew GReturn

🦀
Become crab.
View GitHub Profile
@GReturn
GReturn / eo.c
Created May 9, 2024 10:56
in an array, print even and odd
#include <stdio.h>
int main()
{
int size;
printf("size: ");
scanf("%d", &size);
int arr[size];
@GReturn
GReturn / swit.c
Created May 9, 2024 10:55
swap adjacent elements
#include <stdio.h>
int main()
{
int size;
printf("Enter size of array: ");
scanf("%d", &size);
int arr[size];
@GReturn
GReturn / count.c
Created May 9, 2024 10:44
From 1...n in an array, find missing integers
#include <stdio.h>
int main()
{
int size;
printf("size: ");
scanf("%d", &size);
int arr[size];
for(int i = 0; i < size; i++)
@GReturn
GReturn / mult.c
Created February 22, 2024 08:33
mult table - recursion implementation
#include <stdio.h>
void drawLine(int x, int y)
{
if(x==0) return;
drawLine(x-1, y);
printf("%d\t", x*y);
}
void f(int num)
{
@GReturn
GReturn / dec2bin.c
Created February 19, 2024 15:15
Decimal to Binary - Recursive Implementation
#include <stdio.h>
int dec2bin(int n)
{
if(n/2==0) return n%2;
return (n%2) + dec2bin(n/2)*10;
}
int main(int argc, char const *argv[])
{
printf("%d", dec2bin(5));
@GReturn
GReturn / diamond2.c
Last active February 20, 2024 11:29
Given Width, print Diamond - Recursive Implementation
// given width, print diamond
#include <stdio.h>
void printSpaces(int sp)
{
if(sp <= 0) return;
printf(" ");
return printSpaces(sp-1);
}
void printStars(int st)
@GReturn
GReturn / diamond.c
Last active February 19, 2024 13:21
Print diamond - Recursive Implementation
#include <stdio.h>
void printSpaces(int spaceIndex)
{
if(spaceIndex <= 0) return;
printf(" ");
return printSpaces(spaceIndex-1);
}
void printStars(int starIndex)
{
@GReturn
GReturn / pyramid.c
Last active February 19, 2024 11:31
Print a pyramid - Recursive Implementation
#include <stdio.h>
void printSpaces(int spaceIndex)
{
if(spaceIndex == 0) return;
printf(" ");
return printSpaces(spaceIndex-1);
}
void printStars(int starIndex)
{
@GReturn
GReturn / square.c
Created February 18, 2024 09:27
Square - Recursive Implementation
#include <stdio.h>
void pr(int wid)
{
if(wid == 0)
{
printf("\n");
return;
}
printf("* ");
@GReturn
GReturn / lcm_euclid.c
Created February 17, 2024 11:57
LCM - Recursive (Euclidean Algorithm)
#include <stdio.h>
int gcd(int big, int small)
{
if(big%small==0) return small;
return gcd(small, big%small);
}
int LeastCM(int big, int small)
{