12. ()
void
function_name(void )
#include<stdio.h>
#include<conio.h>
void asterisk_line(void);
void main(void)
{
clrscr( );
asterisk_line( );
printf("****** C and C++ PROGRAMMING ******n");
asterisk_line();
printf("nPress any key back to program ...");
getch();
}
/* asterisk_line function */
17. 7
(Local Variable)
(Global Variable)
(
)
/* 7th Sample Program: Local vs Global Variable */
#include<stdio.h>
int ans = 0;
int inc_one(int); /* function prototype */
void main()
{
int a = 3;
ans = inc_one(a);
printf(“Answer is %dn”, ans);
}
/* function definition: return x+1 */
int inc_one(int x)
{
int ans;
ans = x + 1;
return ans;
}
18. ans
(main)
ans
a
inc_one x ans
ans ans
inc_one ans
inc_one
ans
inc_one ans
ans
C
Header #include
#include<stdio.h>
Square root 4 = 2.000000
5 power 3 = 125.000000
19. #include<math.h>
void main()
{
printf(“square root 4 =”);
printf(“%fn”, sqrt(4));
printf(“5 power 3 =”);
printf(“%f”, pow(5,3));
}
include .h
• printf scanf include
stdio.h
• sqrt pow
include math.h
math.h
double
double
20. sin(), cos() tan()
sin(x) sine x
cos(x) cosine x
(radian)
tan(x) tangent x
(radian)
sqrt(x) x x
exp(x) ex e
pow(x,y) xy
log(x) log e natural logarithm
x
21. log10(x) log x
ceil(x) x x
floor(x) x x
fabs(x)