Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
}
Function Prototype (Declaration)
Syntax:
• Calling a function
line();
• Function prototype (Declaration)
void line(void);
• A prototype declares a function
• A function call executes a function
• A function definition is the function itself
A sound example
Special character ‘\x7’ called Bell
void twobeep(void);
void main(void)
{
twobeep();
printf(“type any character”);
getch();
twobeep();
}
void twobeep(void)
{
long j;
printf(“\x7”);
for(j=1;j<100000;j++)
;
printf(“\x7”);
}
Function that return a value
char getlc(void);
void main(void)
{
char chlc;
printf(“Type ‘a’ for first selection,’b’ for second”);
chlc=getlc();
switch(chlc)
{
case ‘a’:
printf(“\n You typed an ‘a’”);
break;
case ‘b’:
printf(“\n You typed a ‘b’”);
break;
default:
printf(“\n you choose non-existent set”);
}
}
Continued….
char getlc(void)
{
char ch;
ch=getche();
if(ch>64 && ch>91)
ch=ch+32;
return ch
}