Skip to content

Instantly share code, notes, and snippets.

@kylelk
kylelk / cmd_arg.c
Created August 29, 2013 04:57
command line arguments
#include <stdio.h>
main(int argc, char *argv[])
{
int c;
printf("Number of command line arguments passed: %d\n", argc);
for (c = 0; c < argc; c++)
printf("%d. Command line argument passed is %s\n", c + 1, argv[c]);
@kylelk
kylelk / md5.c
Created August 30, 2013 02:28
This is an implementation of the md5 algorithm in C.
//
// sha256_test.c
//
//
// Created by Kyle on 8/10/13.
//
//
/*
* Simple MD5 implementation
@kylelk
kylelk / log.c
Created August 30, 2013 13:50
natural logarithm in C
#include <stdio.h>
#include <math.h>
double fun(double x)
{
return log(x); // base-e logarithm! }
}
// usage
int main()
@kylelk
kylelk / stock_list.txt
Created August 31, 2013 03:34
list of all stocks
FLWS
FCTY
FCCY
SRCE
FUBC
VNET
JOBS
EGHT
AVHI
SHLM
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
public class AESexample {
private String keySize;
private Key aesKey;
//
// hello1.c
//
//
// Created by Kyle on 8/31/13.
//
//
#include <stdio.h>
main()
@kylelk
kylelk / multiplication table.c
Last active December 22, 2015 02:08
multiplication table in C
/* C program to find multiplication table up to 10. */
#include <stdio.h>
int main()
{
int n, i;
printf("Enter an integer to find multiplication table: ");
scanf("%d",&n);
for(i=1;i<=10;++i)
{
printf("%d * %d = %d\n", n, i, n*i);
@kylelk
kylelk / Quadratic Equation.c
Last active December 22, 2015 02:08
Quadratic Equation roots
/* Program to find roots of a quadratic equation when coefficients are entered by user. */
/* Library function sqrt() computes the square root. */
#include <stdio.h>
#include <math.h> /* This is needed to use sqrt() function.*/
int main()
{
float a, b, c, determinant, r1,r2, real, imag;
printf("Enter coefficients a, b and c: ");
scanf("%f%f%f",&a,&b,&c);
@kylelk
kylelk / ASCII.c
Last active December 22, 2015 02:08
ASCII Value
/* Source code to find ASCII value of a character entered by user */
#include <stdio.h>
int main(){
char c;
printf("Enter a character: ");
scanf("%c",&c); /* Takes a character from user */
printf("ASCII value of %c = %d",c,c);
return 0;
}
/* The file name of this C program should be sourcecode.c */
#include<stdio.h>
int main(){
FILE *fp;
char c;
fp = fopen("sourcecode.c","r");
do{
c= getc(fp);
putchar(c);