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

Compile and Execute C Online

c

#include<stdio.h>

int main()
{
 int n,c,s,row;
 
 printf("enter the number of rows in pyramid of stars you wish to see:");
 scanf("%d",&n);
 
 s=n;
 
 for(row=1;row<=n;row++)
 {
    for(c=1;c<s;c++)
     printf(" ");
     
     s--;
    
    for(c=1;c=2*row-1;c++)
     printf("*");
     
    printf("\n");
    
 }
 
 return 0;
}

Thread

c

#include <stdio.h>

#define SIZE_OF_DATA_FROM_DEVICE_DRIVER 10
int datafromDD[], datatobuffer[];
int i = 0;

int readfromDDandwriteTobuffer()
{
    readDatafromDD(datafromDD);
    int j = i-SIZE_OF_DATA_FROM_DEVICE_DRIVER;
    
    
    for( ; j < i ; j++ )
    {
        datatobuffer[j] = datafromDD[j];
        printf("%d ",datatobuffer[j]);
    }
    
    printf("\n");
    
}

void readDatafromDD(int * data)
{
    int limit = i+SIZE_OF_DATA_FROM_DEVICE_DRIVER;
    for( ; i < limit ; i++ )
    {
        data[i] = i;
        //printf("%d",datafromDD[i]);
    }
}

int main(void) {
	printf("hi");
	int x = 0;
	while( x < 10)
	{
	readfromDDandwriteTobuffer();
	    x++;
	}
	return 0;
}


Compile and Execute C Online

c

#include <stdio.h>
int main()
{
    int i,start,dest,fair,n,f[5],sum;
    sum=0;
    f[0]=0;
    f[1]=30;
    f[2]=20;
    f[3]=45;
    f[4]=35;

    printf("\n enter the number of passengers");
    scanf("%d",&n);
    printf("\n station available are:");
    printf("\n 1.shegaon");
    printf("\n 2.paras");
    printf("\n 3.akola");
    printf("\n 4.washim");
    printf("\n 5.hingoli");
    printf("\n select starting station");
    scanf("%d",&start);
    printf("\n select ur destination");
    scanf("%d",&dest);
    switch(start)
    {
        case 1:
        printf("\n STARTING STATION: shegaon");
        break;
        case 2:
        printf("\n STARTING STATION: paras");
        break;
        case 3:
        printf("\n STARTING STATION: akola");
        break;
        case 4:
        printf("\n STARTING STATION: washim");
        break;
        case 5:
        printf("\n STARTING STATION: hingoli");
        break;
    }
    
    switch(dest)
    {
        case 1:
        printf("\t\t ur destination: shegaon");
        break;
        case 2:
        printf("\t\t ur destintion: paras");
        break;
        case 3:
        printf("\t\t ur destination: akola");
        break;
        case 4:
        printf("\t\t ur destination: washim");
        break;
        case 5:
        printf("\t\t ur destination: hingoli");
        break;
    }
    printf("\n no of passengers are:%d",n);
    if(start=dest)
    {
        printf("\n no fair");
    }
    else
    {
        for(i=0;i<dest;i++)
        {
            sum=sum+f[i];
        }
        fair=sum*2*n;
        printf("\n the fair is=%d",fair);

    }
    return(0);
    
}

    
    
    
    
        
        
        
        

ctestpointers

c

#include <stdio.h>

int main()
{
    int someNumber = 0;
    int *pointer = &someNumber;

    printf("Entero guardado en la variable: %x\n", someNumber);
    printf("Dirección de memoria donde está someNumber: %x\n", &someNumber);
    printf("Dirección de memoria donde está someNumber: %x\n", pointer);
    printf("Acceso a el valor de la variable desde el puntero: %x\n", *pointer);
}

Compile and Execute C Online

c

#include <stdio.h>

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

    return 0;
}

Compile and Execute C Online

c

#include <stdio.h>

int main()
{
    int val,i;
    printf("Enter value - >");
    scanf("%d",&val);
    for(i=1;i<=val;i++)
{
    if(val%i==0)
    {
        printf("\n%d",i);
    }
}
return 0;
}

Compile and Execute C Online

c

#include <stdio.h>

int arraysum(int*, int);
void arrprint(int*, int);

int main()
{
    int in[] = {3,-4,2,9,5,1,7};
    
    arraysum(in, 7);

    return 0;
}

int arraysum(int* in, int sz)
{
    int* arr = NULL;
    int i,j,k;
    int maxsum = 0; 
    
    arr = (int*) malloc (sz*sz*sizeof(int));
    
    memset (arr, 0, sz*sz*sizeof(int));
    
    for (i = 0; i < sz; i++) {
        for (j = i; j < sz; j++) {
            arr[i*sz + j] += in[i];
        }
        for (j = i - 1; j >= 0; j--) {
            for (k = i; k < sz; k++) {
              arr[j*sz + k] += in[i];
            }
        }
    }
    arrprint(arr, sz);
    
}

void arrprint(int* in, int sz)
{
    int i, j;
    
    for (i = 0; i < sz; i++) {
        for (j = 0; j < sz; j++) {
            printf ("%d  ", in[i*sz + j]);
        }
        printf("\n");
    }
}

Compile and Execute C Online

c

#include <stdio.h>

void main()
{
    int sum = 0, i;
    i = 1;
    while(i <= 50)
    {
        sum = sum + i;
        printf("%d, ", i);
    }
    
    return 0;
}

Compile and Execute C Online

c

#include <stdio.h>

union d
{
   unsigned short sh;
   unsigned char ch[2];
}hextoi;


union e
{
   unsigned int sh;
   unsigned char ch[4];
}hextobi;

void conversion( unsigned int *ptr_int)
{
    //unsigned short tmp=*((unsigned short *)(ptr_int)+1);
   // tmp= ((tmp<<8)&0xff00)|((tmp>>8)&0x00ff);
    
  *((unsigned short *)ptr_int)= ((*((unsigned short *)ptr_int)<<8)&0xff00)|((*((unsigned short *)ptr_int)>>8)&0x00ff);
  
  *((unsigned short *)(ptr_int)+1) = ((*((unsigned short *)(ptr_int)+1)<<8)&0xff00)|((*((unsigned short *)(ptr_int)+1)>>8)&0x00ff);
  
    
    //printf("Temp: %.2X\n",tmp);
    
}

int main()
{
    //unsigned char a[2]={0x01,0x02};
    hextoi.ch[0]=0x18;
    hextoi.ch[1]=0x98;
    
    hextobi.ch[0]=0x03;
    hextobi.ch[1]=0xE8;
    hextobi.ch[2]=0x01;
    hextobi.ch[3]=0x12;
    
    printf("Data1 -> %.2X %.2X , int -> %.2X\n", hextoi.ch[0],hextoi.ch[1], hextoi.sh);
    
    conversion(&hextobi.sh);
    
    printf("Data2 -> %.2X %.2X %.2X %.2X , int -> %.2X\n", hextobi.ch[0],hextobi.ch[1],hextobi.ch[2],hextobi.ch[3], hextobi.sh);
    
     
    
    //unsigned short a1= (hextobi.sh>>16);
   
    // printf("a1 %.2X\n",a1);
    
    //hextoi.sh = (hextoi.sh<<8)&0xff00;
    unsigned short a = (hextoi.sh<<8)&0xff00;
    unsigned short b = (hextoi.sh>>8)&0x00ff;
    
     unsigned short c=a | b;
    
    printf(">>>>>>> a: %.2x     b: %.2X\n c: %.2X\n",a,b,c);
    
    //hextoi.sh= ((hextoi.sh<<8)&0xff00)|((hextoi.sh>>8)&0x00ff);
    
    printf("Data -> %.2X %.2X , int -> %d\n", hextoi.ch[0],hextoi.ch[1], hextoi.sh);
    
    

    return 0;
}

Compile and Execute C Online

c

#include <stdio.h>

union d
{
   unsigned short sh;
   unsigned char ch[2];
}hextoi;


union e
{
   unsigned int sh;
   unsigned char ch[4];
}hextobi;

void conversion( unsigned int *ptr_int)
{
    //unsigned short tmp=*((unsigned short *)(ptr_int)+1);
   // tmp= ((tmp<<8)&0xff00)|((tmp>>8)&0x00ff);
    
  *((unsigned short *)ptr_int)= ((*((unsigned short *)ptr_int)<<8)&0xff00)|((*((unsigned short *)ptr_int)>>8)&0x00ff);
  
  *((unsigned short *)(ptr_int)+1) = ((*((unsigned short *)(ptr_int)+1)<<8)&0xff00)|((*((unsigned short *)(ptr_int)+1)>>8)&0x00ff);
  
    
    //printf("Temp: %.2X\n",tmp);
    
}

int main()
{
    //unsigned char a[2]={0x01,0x02};
    hextoi.ch[0]=0x18;
    hextoi.ch[1]=0x98;
    
    hextobi.ch[0]=0x03;
    hextobi.ch[1]=0xE8;
    hextobi.ch[2]=0x01;
    hextobi.ch[3]=0x12;
    
    printf("Data1 -> %.2X %.2X , int -> %.2X\n", hextoi.ch[0],hextoi.ch[1], hextoi.sh);
    
    conversion(&hextobi.sh);
    
    printf("Data2 -> %.2X %.2X %.2X %.2X , int -> %.2X\n", hextobi.ch[0],hextobi.ch[1],hextobi.ch[2],hextobi.ch[3], hextobi.sh);
    
     
    
    //unsigned short a1= (hextobi.sh>>16);
   
    // printf("a1 %.2X\n",a1);
    
    //hextoi.sh = (hextoi.sh<<8)&0xff00;
    unsigned short a = (hextoi.sh<<8)&0xff00;
    unsigned short b = (hextoi.sh>>8)&0x00ff;
    
     unsigned short c=a | b;
    
    printf(">>>>>>> a: %.2x     b: %.2X\n c: %.2X\n",a,b,c);
    
    //hextoi.sh= ((hextoi.sh<<8)&0xff00)|((hextoi.sh>>8)&0x00ff);
    
    printf("Data -> %.2X %.2X , int -> %d\n", hextoi.ch[0],hextoi.ch[1], hextoi.sh);
    
    

    return 0;
}

Advertisements
Loading...

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