Function Prototypes

Function Prototypes - void load(); //prototypes void...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// This program demonstrates function prototypes #include <stdio.h> int x,y,z,sum; //global variables declared outside functions float avg; //can be used anywhere in program // global variables cause side effects: one function messes up another // local variables are declared and can only be accessed inside function //prototypes: tell c++ what functions are coming
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: void load(); //prototypes void calc(); //prototypes void print(); //prototypes void main() { load(); calc(); print(); } void load() { printf(&quot;Enter 3 numbers&quot;); scanf(&quot;%d%d%d&quot;,&amp;x,&amp;y,&amp;z); } void calc() { sum=x+y+z; avg=sum/(float)3; } void print() { printf(&quot;The sum is %d\n&quot;,sum); printf(&quot;The avg is %f\n&quot;,avg); }...
View Full Document

Ask a homework question - tutors are online