This file contains 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
var BASE64_MARKER = ';base64,'; | |
convertDataURIToBinary(dataURI) { | |
const base64Index = dataURI.indexOf(this.BASE64_MARKER) + this.BASE64_MARKER.length; | |
const base64 = dataURI.substring(base64Index); | |
const raw = window.atob(base64); | |
const rawLength = raw.length; | |
const array = new Uint8Array(new ArrayBuffer(rawLength)); | |
for (let i = 0; i < rawLength; i++) { | |
array[i] = raw.charCodeAt(i); | |
} |
This file contains 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<string.h> | |
#include<math.h> | |
#include<stdlib.h> | |
int main(int argc,char *argv[]){ | |
int base=atoi(argv[1]),height=atoi(argv[2]); | |
float ans= 0.5 * base * height; | |
printf("%0.2f\n",ans); | |
return 0; |
This file contains 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<string.h> | |
#include<math.h> | |
#include<stdlib.h> | |
int main(int argc,char *argv[]){ | |
int r=atof(argv[1]); | |
float ans=3.14*r*r; | |
printf("%f\n",ans); | |
return 0; |
This file contains 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
//decimal to binary | |
#include<stdio.h> | |
#include<string.h> | |
#include<math.h> | |
#include<stdlib.h> | |
int main(int argc,char *argv[]){ | |
int n=atoi(argv[1]); | |
int binaryNum[1000]; | |
int i = 0; | |
while (n > 0) { |
This file contains 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
//check string is palindrome | |
#include <stdio.h> | |
#include<string.h> | |
#include<stdbool.h> | |
int main(int argc,char* argv[]) | |
{int l=0;int h=strlen(argv[1])-1; | |
char *str=argv[1]; | |
bool tmp=true; | |
while (h > l) | |
{ |
This file contains 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
// check number is prime | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(int argc,char *argv[]) | |
{int n=atoi(argv[1]);int i; | |
int c=0; | |
for( i=2;i<n/2;i++) | |
{ | |
if(n%i==0) | |
{ |
This file contains 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
//binary to decimal | |
#include<stdio.h> | |
#include<string.h> | |
#include<math.h> | |
#include<stdlib.h> | |
int main(int argc,char *argv[]){ | |
char *a;a=argv[1]; | |
int len=strlen(a);int tmp=len-1; | |
int i=0;int ans=0; |
This file contains 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 using command line | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(int argc,char* argv[]) | |
{ | |
int n=atoi(argv[1]); | |
int ans=1;int i=1; | |
for(i=1;i<=n;i++) | |
{ | |
ans=ans*i; |
This file contains 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
// C program for insertion sort | |
#include <stdio.h> | |
#include <math.h> | |
/* Function to sort an array using insertion sort*/ | |
void insertionSort(int arr[], int n) | |
{ | |
int i, key, j; | |
for (i = 1; i < n; i++) | |
{ |
This file contains 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
// Optimized implementation of Bubble sort | |
#include <stdio.h> | |
void swap(int *xp, int *yp) | |
{ | |
int temp = *xp; | |
*xp = *yp; | |
*yp = temp; | |
} | |
NewerOlder