global variables in C
/* program to input a number from a different file using external variable and print that
*/
step1:
in devc++,
->click file menu
->click new
->project
->choose c project
->click ok
step 2
under 'main.c' write the code
#include <stdio.h>
extern int a;
void input();
int main()
{
input();
printf("a=%d",a);
return 0;
}
-------
step 3
->right click the project folder on left side
Here we have taken as untitled3.c
->write the following code
#include<stdio.h>
int a;
void input()
{
scanf("%d",&a);
}
->save it
->run the program
No comments:
Post a Comment