
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
What are executable statements in C language?
A ‘C’ program contains executable statements. A compiler helps to translate the executable statements into machine language.
When a user runs the program, he/she machines the language statements which are executed by the compiler.
Types of executable statements
The types of executable statements in C language are as follows −
- Input – output statements
- Assignment statements
Input-output statements
Storing a value into memory is called ‘input operation’.
After executing the computations, the results are stored in memory and the results can be displayed to the user by ‘output operation’.
All i/o operations are performed using input / output functions.
The most common I/O functions are supplied through the preprocessor directive # include<stdio.h>.
The most commonly used I/O functions are printf ( ) and scanf ( ).
printf ( ) function
The syntax is as follows −
printf("format string", print list);
For example,
printf ("average of 3 numbers = %f",avg);
The printf ( ) displays the value of its format string
scanf ( ) function
The syntax is as follows −
scanf ("format string", input list);
For example, scanf ("%d %f", &a, &b);
The scanf ( ) copies data typed at the keyboard into memory during program execution.
The input list is preceded by ampersand ( &).
Assignment statements
The assignment statements store a value in a variable and is used to perform arithmetic operations in a program.
Syntax
The syntax is as follows −
variable=expression
For example,
- c = a+b;
- avg = sum/3;
- r1 = (b*b – 4 * a*c);
Example
Following is the C program for computing an average of three numbers −
#include<stdio.h> #include<stdio.h> main(){ int a,b,c,d; float avg; printf("Enter values for a,b,c:
"); scanf("%d%d%d",&a,&b,&c);// The scanf ( ) copies data typed at the keyboard into //memory during program execution. d=a+b+c; //assignment stmt avg=d/3; printf("Average avg=%f",avg); }
Output
You will see the following output −
Enter values for a,b,c:2 3 4 Average avg=3.000000
- Related Articles
- What are the loop control statements in C language? Explain with flow chart and program
- What are control statements in C#?
- What are nested structures in C language?
- What are string literals in C language?
- What are macros in C programming language?
- What are relational operators in C language?
- What are memory operations in C language?
- What are decision making statements in C#?
- Nested for loop and other related statements in C language
- What are the predefined functions in C language?
- What are Backslash character constants in C language?
- What are primary data types in C language?
- What are the shift operations in C language?
- What are pointers to structures in C language?
- What are string searching functions in C language?
