{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS110_03a_FcnExamples.c - void incr x=x 10 Output Please...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Function Examples #include<stdio.h> int absolute_value (int); main () { int num; printf(“Enter a number: ”); scanf(“%d”, &num); printf(“The absolute value of %d is %d\n”, \ num, absolute_value(num)); } int absolute_value (int x) { if (x >= 0) return x; else return -x; } 8
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Function Examples #include<stdio.h> void table(int); main () { int num; printf(“Enter a number: ”); scanf(“%d”, &num); table(num); } void table (int x) { int i; for (i=1; i<=10; i++) printf(“%d * %d = %d\n”, i, x, i*x); } 9
Image of page 2
Function Examples #include<stdio.h> void table(int); main () { int i; printf(“Enter a number: ”); scanf(“%d”, &i); table(i); } void table (int x) { int i; for (i=1; i<=10; i++) printf(“%d * %d = %d\n”, i, x, i*x); } 11
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon