Partially changed file structure to suit VSCode
This commit is contained in:
28
LC12/Global1/global_ex1.c
Normal file
28
LC12/Global1/global_ex1.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
This makes global variables look like a good idea
|
||||
|
||||
THEY ARE NOT - DO NOT USE THEM
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int y,k,ans; /* Define GLOBAL variables */
|
||||
|
||||
void NastyGlobalFunction (void ) /* Define function */
|
||||
{
|
||||
ans = ( y * k ); /* y, k and ans are defined globally above */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main( void )
|
||||
{
|
||||
y = 2; /* Set value of y */
|
||||
k = 3; /* Set value of k */
|
||||
|
||||
NastyGlobalFunction(); /* call the function */
|
||||
|
||||
printf("%d multiplied by %d is %d " ,y ,k ,ans ); /* Display values */
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user