Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

hex decoder

c

#include <stdio.h>

int main()
{
    unsigned int hex = 4;
    int dir, decode_dir[4] = {0x8, 0x4, 0x2, 0x1};
    int test_dirs[4] = {-1, -1, -1, -1};
    printf("%1x\n\n", hex);
    
    for(int i = 0; i < 4; i++){
        dir = hex & decode_dir[i];
        if(dir!=0){
            test_dirs[i] = 1;    
        } else {
            test_dirs[i] = 0;
        }
        printf("test_dirs[%d]: %d\n\n",i, test_dirs[i]);    
    }
    
    return 0;
}

Compile and Execute C Online

c

//Lisa Scherer
//7 Sep 2017
//Homework #2
//1. Write a program that prints out this sentence "My Name is:" */

//include standard IO
#include <stdio.h>

//int main ()
int main()

{
//to display "my name is"
//printf "my name is:"
    printf("My name is:\n");

    return 0;
}

myfrirstprogram

c

#include <stdio.h>

int main()
{
    printf("Hello, World!\n");

    return 0;
}

Compile and Execute C Online

c

#include <stdio.h>

int main()
{
    int numero=0, resto=0;
    
    printf("Digite um numero inteiro: ");
    scanf("%d", &numero);
    
    resto=numero%2;
    
    if(resto==0)
        printf("\nSeu numero é par\n");
        
    if(resto==1)
        printf("\nSeu numero é impar\n");
        
    return 0;
}

gaer

c

#include <stdio.h>
#include <stdlib.h>
 
int indice = 0;
int *vet;
const int tamanho = 120012;
 
void inicializar_ecg ()
{
  int aux[16];
  FILE *f;
  vet = malloc (tamanho * sizeof (int));
  f = fopen ("s0559.txt","r");
  for (int i=0; i<tamanho; i++) {
    for (int j=0; j<16; j++)
      fscanf (f,"%d",&aux[j]);
    vet[i] = aux[9];
  }
  fclose (f);
}
 
void obter_amostras (double *v, int *n)
{
  if (indice < tamanho) {
    *n = 1;
    *v = vet[indice];
    indice = indice + 1;
  }
  else {
    *n = 0;
    *v = 0;
  }
}

Unsigned 1s Bit Count

c

#include <stdio.h>

int binaryCount(unsigned int n) {
       int onesCount;
        while (n != 0) {
            if(n%2 == 1){
                onesCount++;
                n=n/2;
            }
            else {
                n=n/2;
            }
        }
    return onesCount;    
        
    }

int main(int argc, int *argv[]) {
    int x;
    if (argc == 2) {
        x = (unsigned int)argv[1];
    }
    else {
        printf("No arguments supplied!");
    }
   // int x = 4294967295u;
    int ones = 0;
    ones = binaryCount(x);
    printf("%d", ones);
    return 0;
}

Compile and Execute C Online

c

#include <stdio.h>
#include<math.h>

int main()
{
    float x,t,s,k,acc=0.00001;
FILE *fp=NULL;
fp=fopen("bessel.txt","w");
for(x=0.0;x<=10.0;x+=0.1)
{ t=1.0;
s=t;
k=0;
do
{ t*=(-1)*x*x/(4*(k+1)*(k+2));
 s+=t;
 k+=1;}
 while(fabs(t/s)>acc);
    fprintf(fp,"%f \t %f\n",x,s);}

    return 0;
}

ooooooo

c

#include <stdio.h>

int main()
{
    printf("Hello, World!\n");

    return 0;
}

Bhasvic Computer Science Chapter 1 - 4

c

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float val1=0,val2=0,val3=0;
    int error=0;
    printf("Enter two numbers separated by a ',':\n");
    fflush(stdin);
    error=scanf("%f,%f",&val1,&val2);
    val3=val1*val2;
    printf("%f X %f = %f\n",val1,val2,val3);
    printf("Error code: %d\n",error);
}

blah

c

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct {
    int x;
    char *y;
} A;

typedef struct {
    A a;
    int z;
    char *n;
} B;

void do_thing(B* ptr){
    memset(ptr, 0, sizeof(B));
    ptr->a.x = 2;
    ptr->z = 3;
    ptr->n = 0;
}

int main()
{
    B* ptr = (B*)malloc(sizeof(B));
    
    do_thing(ptr);
    
    printf("%d %d %d", ptr->a.x, ptr->z, ptr->n);

    return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.