Global Variable in C1 min read

Global variables in C are declared outside any functions and usually at the top of the program as shown below. They can be used in the program inside any block of code.

Properties of a Global Variable:

  • Global variables are defined outside a function, usually on top of the program.
  • The lifetime of a Global Variable is throughout the program and can be accessed to any function or block.

Example: C Program for Local Variable

The Output of Global Variable in C.


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More