Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What are executable statements in C language?
Executable statements in C are instructions that perform specific actions during program execution. The compiler translates these statements into machine code, which the processor can execute directly.
Syntax
statement;
Types of Executable Statements
The main types of executable statements in C language are −
- Input-output statements
- Assignment statements
- Control flow statements
- Function call statements
Input-Output Statements
Input-output statements handle data exchange between the program and the user −
- Input operation − Storing values from external sources into memory
- Output operation − Displaying computed results to the user
- These operations use functions from
<stdio.h>header file
printf() Function
The printf() function displays formatted output −
printf("format string", variable_list);
scanf() Function
The scanf() function reads formatted input from keyboard −
scanf("format string", &variable_list);
Assignment Statements
Assignment statements store values in variables and perform arithmetic operations −
variable = expression;
Examples −
c = a + b;avg = sum / 3;result = (b * b - 4 * a * c);
Example: Complete Program with Executable Statements
Following program demonstrates various executable statements to compute average of three numbers −
#include <stdio.h>
int main() {
int a, b, c, sum;
float avg;
/* Input statement */
printf("Enter three numbers: ");
scanf("%d %d %d", &a, &b, &c);
/* Assignment statements */
sum = a + b + c;
avg = (float)sum / 3;
/* Output statement */
printf("Average = %.2f<br>", avg);
return 0;
}
Enter three numbers: 10 20 30 Average = 20.00
Key Points
- Every executable statement must end with a semicolon (;)
- Statements are executed sequentially unless controlled by flow control statements
- Input operations require address operator (&) with variable names
- Type casting may be needed for accurate calculations
Conclusion
Executable statements form the core of C programs by performing actual operations like input, output, calculations, and data manipulation. Understanding these statement types is fundamental for writing effective C programs.
