Skip to content

Instantly share code, notes, and snippets.

View silven-mohan's full-sized avatar
🎯
Focusing

Silven Mohan silven-mohan

🎯
Focusing
View GitHub Profile
@silven-mohan
silven-mohan / hello.asm
Created September 26, 2025 13:36
This program prints Hello, World in Assembly Programming Language.
;Hello World Program
section .data
msg db "Hello, World! From Assembly.", 0xA ; newline-terminated string
len equ $-msg ; length of the string
section .text
global _start
_start:
mov rax, 1 ; syscall for write.
@silven-mohan
silven-mohan / Char_Cycler.c
Created August 16, 2025 15:30
This program brute-forces through printable ASCII characters to visually “crack” and reveal a target string with a retro hacker-style animation.
//Preprocessing Directives
#include<stdio.h> //For printf().
//Function Prototypes
void Char_Cycler(const char *str);
void delay(void);
//Function Definition
void Char_Cycler(const char *str)
{
@silven-mohan
silven-mohan / Manual_String_Operations.c
Created August 16, 2025 15:28
This Gist contains the manual string operations like strcpy, strcat, strcmp, strlen.
//Preprocessing Directives
#include<stdio.h> //For printf().
//Function Prototypes
int my_strcmp(const char *str1, const char *str2);
void my_strcat(char *dest, const char *src);
void my_strcpy(char *dest, const char *src);
int my_strlen(const char *str);
//Function Definitions
@silven-mohan
silven-mohan / Single_Liners_1.c
Created August 13, 2025 09:08
A collection of beginner-level C problems solved in a single logical line.
// Preprocessing Directives
#include<stdio.h> // For printf().
#include<string.h> //For strlen().
//Number Swapping
//Swaps any two numbers in a single-line using function-like macros.
#define SWAP(x, y) do{int temp=x; x=y; y=temp;}while(0) // The do-while(0) runs a single time.
int main()
{
int a=5, b=6, no=120, s=0, i, n=10, f0=0, f1=1, f;
//Dependencies
#include<stdio.h> // For printf(), scanf(), etc,.
//Function Prototypes
int NumForge(int arr[], int size, int DigitSize);
// NumForge
// Takes an array of numbers, size of the array, size of the number to be created.
// Promts the user for largest/smallest number.
// Sorts out the array using bubble sort.
// Dependencies
#include<stdio.h> // For printf(), scanf(), etc,.
//Function Prototypes
int Binary_Search(int arr[], int size, int s);
// Binary Search
// Searches for an element in an array sorteed in ascending order.
// If the Search element is equal to middle element of the array, the search is complete.
// If the Search element is less than the middle element of the array, the search continues on the left sub-array.
// Dependencies
#include<stdio.h> // For printf(), scanf(), etc,.
//Function Prototypes
int Linear_Search(int arr[], int s, int size);
// Linear Search
// Searches the element 's' in the array 'arr' of size 'size'.
// Prints the index of the element if found.
int Linear_Search(int arr[], int s, int size)
@silven-mohan
silven-mohan / Collatz_Conjecture.c
Created July 29, 2025 12:59
This conjecture states that no matter what positive integer you start with, the sequence will always eventually reach 1.
//Function Prototypes
int Collatz_Conjecture(int n);
//Collatz Conjecture
int Collatz_Conjecture(int n)
{
while(n!=1)
{
// If Even Number
if(n%2==0)
@silven-mohan
silven-mohan / Greatest_Common_Divisor.c
Created July 29, 2025 12:29
This program helps you to find the Greatest Common Divisor of any two Positive numbers.
// Function Prototypes
int GCD(int a, int b);
// Greatest Common Divisor
int GCD(int a, int b)
{
int i, c, d, temp;
if(b==0)
{
printf("GCD of %d and %d is %d", a, b, a);
@silven-mohan
silven-mohan / Least_Common_Multiple.c
Last active July 30, 2025 06:19
This program helps you find the Least Common Multiple of any two positive numbers.
// Function Prototypes
int LCM(int a, int b);
int GCD(int a, int b);
// Least Common Multiple
int LCM(int a, int b)
{
int LCM;
LCM=(a*b)/(GCD(a, b));
printf("\nLCM of %d and %d is %d", a, b, LCM);