Some important points to be note about Global variable declaration are:
It can be used anywhere within the program. Unlike local variables that can be used within the scope of a particular function.
& is used to assign the input value to the variable and store it at that particular location.
%0nd is used to represent numbers in n digit format with leading 0’s.
#include<stdio.h>
#include<conio.h>
int a,b;
void main()
{
clrscr();
printf("Enter the two values to find the greatest and smallest number: \n");
scanf("%d%d", &a, &b);
if(a == b)
printf("\n\nBoth are equal");
else if(a < b)
{
printf("\n\nThe largest number is %03d\n", b);
printf("\nThe smallest number is %03d\n", a);
}
else //Only possibility remaining
{
printf("The largest number is %03d\n", a);
printf("The smallest number is %03d\n", b);
}
getch();
}
OutPut
Enter the two values to find the greatest and smallest number: 10 7 The largest number is 010 The smallest number is 007