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("Enter 3 numbers"); scanf("%d%d%d",&x,&y,&z); } void calc() { sum=x+y+z; avg=sum/(float)3; } void print() { printf("The sum is %d\n",sum); printf("The avg is %f\n",avg); }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online