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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
int compare(void *a, void *b) | |
{ | |
int * ap = a; | |
int * bp = b; | |
return *ap - *bp; | |
} | |
void * lsearch(void *key, void *base, int n, int elemsize) |
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
/* compile using "gcc -o wc <file.c>" and work just like wc only tested on asci text file*/ | |
#include<stdlib.h> | |
#include<stdio.h> | |
#include<string.h> | |
#include<unistd.h> | |
FILE * getFileBuffer(char * file_name); | |
int lineCount(char * filepath); | |
int wordCount(char * filepath); |
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
*/ Usage : <a.uot> <Number> "> | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
int main(int argc, char **argv){ | |
int num = atoi(argv[1]); | |
printf("%d : ", num); | |
char * oneToText[] = {"", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen","Nineteen" }; | |
char * tenToText[] = {"", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"}; |
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
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
int main(int argc, char **argv) | |
{ | |
int num = atoi(argv[1]); | |
char * oneToText[] = {"", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen","Nineteen" }; | |
char * tenToText[] = {"", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"}; | |
char * moreThenHundredToText[] = {"", "Hundred", "Thousand", "Lakhs", "Crore"}; |
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
unsigned long long int find_reverse_number(unsigned long long int nth) { | |
unsigned long long int result = 0, count = 0; | |
for ( unsigned long long int i = 0; i <= 10000000000; i++) | |
{ | |
unsigned long long int reversed = 0, remainder; | |
unsigned long long int n = i; | |
while (n != 0) | |
{ | |
remainder = n % 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
/*Doesn't work on 970*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
unsigned long long int next_smaller_number(unsigned long long int number); | |
int main(int argc, char const *argv[]) | |
{ | |
unsigned long long int result = 0; |
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
include<stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char const *argv[]) | |
{ | |
factorial(5); | |
return 0; | |
} | |
char *factorial(int n) |
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 will break after sum reachs to int holding limit which is around 4 billion*/ | |
/* Usage : gcc -o fib <file.c> --std=c99 | |
./fib <number> | |
*/ | |
#include <stdlib.h> | |
#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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include <assert.h> | |
int *cache(int n); | |
int canSum(int target, int numbers[], int len, int *memo); | |
int main(int argc, char const *argv[]) | |
{ | |
assert(canSum(11, (int[]){1, 4}, 2, cache(11))); |
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
/* IF YOU WANT TO SORT IN DESCENDING ORDER */ | |
int cmp(const void *a, const void *b) | |
{ | |
const int *A = a, *B = b; | |
/* a>b => -1, a<b => 1, a==b => 0 */ | |
return (*A < *B) - (*A > *B); | |
} | |
/* FOR ASCENDING ORDER SORT*/ | |
int cmp(const void *a, const void *b) |
OlderNewer