end main main function local to main void

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ar x); double varglb1; /* prototype 1 */ /* prototype 2 */ /* global variable */ int main(void){ int localvar; ... } /* end main */ /* main function */ /* local to main */ void one(int anarg, double second) { /* function header 1 int onelocal; /* local to f1 */ ... } /* end one */ int varglb2; int fun_two(int one, char anarg) { int localvar; ... } /* end fun_two */ */ /* global variable */ /* function header 2 /* local to f2 */ */ 3 /* Simple example of variable name scope */ #include <stdio.h> void testscope(int j); int i = 0; /* global declaration */ int main(void) { int j = 0; i++; /* local declaration */ testscope(i); printf("Testing the scope of variables i and j\n"); printf("i = %d, j = %d\n", i, j); } return(0); void testscope(int j) { /* formal paramter = local */ for(i=0; i<100; i++) { j...
View Full Document

This document was uploaded on 03/10/2014 for the course ENGINEER 2sh4 at McMaster University.

Ask a homework question - tutors are online