This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/LC12/global_ex1.c
2022-04-07 16:58:01 +01:00

28 lines
567 B
C

/*
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;
}