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()
{
    printf("Hello, World!\n");
    printf("Hello, \n");

    return 0;
}

Compile and Execute C Online

c

 #include <stdio.h>
/*
* Pablo Muñiz Rocandio
* 09/13/2017
* CS 112
* Mileage Reimbursement Calculator
*
* This program calculates the distance that you have travelled and how much is it cost to you, by entering the beggining odometer reading and the ending odometer reading
*/
int main()
#define MONEY_PER_MILE 0.35
{
    float beginningodometer ;
    float endingodometer ;
    
    printf("Enter beginning odometer reading:%.2f\n",beginningodometer = 3657.34 );
    printf("Enter ending odometer reading:%.2f\n",endingodometer = 3800.34);
    scanf("%.2f %.2f",&beginningodometer,&endingodometer);
    float difference = endingodometer - beginningodometer;
        scanf("%.2f - %.2f = %.2f\n",&endingodometer,&beginningodometer,&difference);
        printf("You travelled %.2f  miles\n",difference);
    float product = difference * MONEY_PER_MILE;
        scanf("%.2f * %.2f = %.2f",&difference,MONEY_PER_MILE,&product);
        printf("At $0.35 per mile, your reimbursement is $%.2f\n",product);
    

    return 0;
}

sunil

c

#include <stdio.h>

void main()
{
	  printf("%x",-1<<4);
}

test

c

#include <stdio.h>

int main()
{
    //Declaring variables
    int year=0;
    int month=0;
    int day=0;
    
    printf("Enter year\n");
    scanf("%d",&year);
    
    printf("Enter month");
    scanf("%d",&month);
    
    printf("Enter day");
    scanf("%d",&day);
    
    printf("\n\n"); //printing two blank lines
    printf("Formatted Output: %d/%d/%d\n",month,day,year);
    
    return 0;
}

Hello-world

c

#include <stdio.h>

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

    return 0;
}

Binary to Decimal Bit Counter

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 x = 4294967295u;
    int ones = 0;
    ones = binaryCount(x);
    printf("%d", ones);
    return 0;
}

Palindrome

c

#include <stdio.h>
#include <stdlib.h>
int main ()
{
  int x[6];
// the array looks like, 012345
  int a, b, c, d, i;
  a = 100;
  b = 100;
  c = 100;
  d = 100;
  do
    {
      i = a * b;
// i  is the product of a and b
      x[0] = (i / 100000);
// sets i/100000 as the first digit of the number Ex. 987654/100000=9.8 sets x[0] as 9
      x[1] = (i / 10000) - (x[0] * 10);
// sets (i/10000) - the first digit*10 as the second number Ex. 987654 / 100000=9.8=9, 987654 / 10000=98 then 98  -  (x[0]*10)=8, sets x[1] as 8
      x[2] = (i / 1000) - (x[0] * 100) - (x[1] * 10);
      x[3] = (i / 100) - (x[0] * 1000) - (x[1] * 100) - (x[2] * 10);
      x[4] =
	(i / 10) - (x[0] * 10000) - (x[1] * 1000) - (x[2] * 100) -
	(x[3] * 10);
      x[5] =
	(i / 1) - (x[0] * 100000) - (x[1] * 10000) - (x[2] * 1000) -
	(x[3] * 100) - (x[4] * 10);

      if (a < 1000)
	{
	  a++;
	}
// as long as A is less than 1000 it will add 1 to A
      else
	{
	  a = d;
	  d++;
	  b = c + 1;
	  c = b;
	}
// if A is 1000 it will turn A back to 100, add 1 to the returning number, adds 1 to B also to multiply every number from 1 to 1000 by every number 1 to 1000
      if (x[0] == x[5] && x[1] == x[4] && x[2] == x[3] && x[0] != 0 && x[0] == 9)
	{
	  printf ("%d%d%d%d%d%d\n", x[0], x[1], x[2], x[3], x[4], x[5]);
	}
// checks if it is a palindrome, 123321 or 554455 etc
    }
  while (a < 1001);
  return 0;
}

lab_01_01.c

c

#include <stdio.h>
void main() {
printf("Hello World!\n");
}

Compile and Execute C Online

c

#include <stdio.h>
/*
многострочный
комментарий
*/
void main() {
    // комментарий до конца строки
    int x = 13;
    int y = 4;
    printf("x + y = %d \n", x + y); // сложение целых чисел
    printf("x - y = %d \n", x - y); // вычитание целых чисел
    printf("x * y = %d \n", x * y); // умножение целых чисел
    printf("x %% y = %d \n", x % y); // остаток от деления целых чисел
    printf("x / y = %d \n", x / y); // деление целых чисел
    double a = 11.7,
           b = 3.5;
    printf("a / b = %lf \n", a / b); // деление вещ. чисел
    printf("x + a = %lf \n", x + a); // сложение целых и вещ. чисел
    char c1 = 10,
         c2 = 100;
    printf("c1 + c2 = %d \n", c1 + c2);
    // пример взаимозаменяемых операторов
    int i = 15;
    printf("i = %d \n", i);i = i + 1;
    printf("i=i+1 : %d \n", i);
    i++;
    printf("i++ : %d \n", i);
    i += 1;
    printf("i+=1 : %d \n", i);
    // экспоненциальный формат
    double d = -5.438754e3,
           f = 1.3e-7;
    int dInt = (int) d;
    printf("d= %lf \n", d);
    printf("dInt = %d \n", dInt);
}

test12323222q212222222222222

c

#include <stdio.h>

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

    return 0;
}

Advertisements
Loading...

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