A NULL statement is a statement that does not perform any action. It consists
of only a semicolon (;) and is used when the syntax of the programming language
requires a statement, but no operation needs to be executed.
;
#include
int main() {
int i = 1;
while (i
Sometimes, the work of the loop is performed within the condition or update expression, making an empty loop body necessary.
#include
int main() {
int i;
for (i = 0; i < 5; i++)
; // NULL statement
printf("Value of i = %d", i);
return 0;
}
In this example, the semicolon (;) acts as the loop body. The loop executes
until the condition becomes false, but no statements are executed inside the loop.
#include
int main() {
int num = 10;
if (num > 0)
; // NULL statement
printf("Program continues...");
return 0;
}
Here, the if condition is checked, but no action is performed when the condition is true.
A NULL statement is an empty statement represented by a single semicolon
(;). It performs no operation and is commonly used when a statement is required
syntactically, but no action needs to be taken.