Пример #1
0
/* return the available free swap space in unit of MB */
uint64_t
get_free_swap(void)
{
	struct anoninfo ai;
	unsigned freemem;

	if (swapctl(SC_AINFO, &ai) != -1) {
		/* in the unit of KB */
		freemem = (int)(ctok(ai.ani_max) - ctok(ai.ani_resv));
	}
	else
		freemem = 0;

	return (freemem/1024);
}
int main()
{
          double c = 0;                         // declare input variable
           cin >> c;                                // retrieve temperature to input variable
          double k = ctok(c);           // convert temperature
          cout << k << "/n" ;                 // print out temperature
}
int main()
{
    double c = 0;
    cin >> c;
    double k = ctok(c);
    cout << k << '\n';
}
Пример #4
0
int
main()
{
    double c = 0;
    cin >> c;
    double k = ctok(c);
    cout << k << endl;
}
int main()
try {
          double c = 0;                         // declare input variable
           cin >> c;                                // retrieve temperature to input variable
          double k = ctok(c);           // convert temperature
          cout << k << "/n" ;                 // print out temperature
}
catch (DegreeErrror) {
		  cerr << "Degree error\n";
}
int main()
try {
			char d;
			double t = 0;                         // declare input variable
			cout << "Please, choose the type of conversion (c for Celsius to Kelvin and k for Kelvin to Celsius)\n";
			cin >> d;                                         // retrieve temperature to input variable
		  	cout << "Please, enter the number\n";
           cin >> t;                                         // retrieve temperature to input variable
          double k = ctok(t, d);           // convert temperature
          cout << k << "/n" ;                 // print out temperature
}
catch (DegreeErrror) {
		  cerr << "Degree error\n";
}
Пример #7
0
int main ()
{
	double c = 0;	// declare input variable
	cin >> c;		// retrieve temperature to input variable

	double k = ctok(c);		// retrive result of celsius to kelvin

	cout << k << endl;		// print out temperature

	
	cin >> c;	// retrieve temperature to input variable again.

	double cel = ktoc(c);	// retrive result of kelvin to celsius

	cout << cel << endl;	// print out temperature

	keep_window_open();
}
Пример #8
0
int main(int argc, char* argv[])
{
    if (argc != 3) {

        print_help(argv[0]);
        exit(EXIT_FAILURE);
    }

    char* endptr = NULL;

    errno = 0;
    float temp = strtof(argv[2], &endptr);

    if (errno || *endptr)
        die("Your temperature is not a valid number.");

    puts("Your argument converts to:");
    switch (argv[1][1]) {

    case 'c':
        printf("%.2fK\n", ctok(temp));
        printf("%.2fF\n", ctof(temp));

        break;

    case 'f':
        printf("%.2fC\n", ftoc(temp));
        printf("%.2fK\n", ftok(temp));

        break;

    case 'k':
        printf("%.2fC\n", ktoc(temp));
        printf("%.2fF\n", ktof(temp));

        break;

    default:
        die("Unknown temperature type");
    }

    return EXIT_SUCCESS;
}