File: rogers_example05a.c

package info (click to toggle)
lg-issue39 2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,408 kB
  • ctags: 145
  • sloc: ansic: 207; perl: 72; makefile: 37; sh: 4
file content (42 lines) | stat: -rw-r--r-- 656 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>

/*

	This program is written to demonstrate the <stdlib.h> library.

	This program will demonstrate integer math

	Written by James M. Rogers

	17 March 1999

	Released to the Public Domain on this date.

*/

main(){

	int a, b;
	long int c, d;
	div_t x;
	ldiv_t y;

	a = 10;
	b = 3;

	x = div(a, b);
	printf(" div (%d, %d) returns a quotient of %d and a remainder of %d\n", a, b, x.quot, x.rem);

	c = 1000000;
	d = 337;

	y = ldiv(c, d);
	printf(" div (%d, %d) returns a quotient of %d and a remainder of %d\n", c, d, y.quot, y.rem);

	a = -100;

	b = abs(a);
	printf("The absolute value of %d is %d\n", a, b);

}