. The most commonly used I/O functions are printf() and scanf(). print"/> . The most commonly used I/O functions are printf() and scanf(). print">

Home  >  Article  >  Backend Development  >  In C language, executable statements refer to code statements that can be executed by the computer.

In C language, executable statements refer to code statements that can be executed by the computer.

PHPz
PHPzforward
2023-08-25 14:29:161358browse

In C language, executable statements refer to code statements that can be executed by the computer.

A "C" program contains executable statements. Compilers help translate executable statements into machine language.

When a user runs a program, he/she executes machine language statements through the compiler.

Types of executable statements

The types of executable statements in C language are as follows:

  • Input and output statements
  • Assignment statements

Input and output statements

  • Storing values ​​into memory is called "input operation".

  • After a calculation is performed, the results are stored in memory and can be displayed to the user through an "output operation".

  • All input/output operations are performed using input/output functions.

  • The most common I/O functions are provided through the preprocessing directive #include.

  • 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);
  • 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);

  • scanf() copies data typed on the keyboard to memory during program execution.

  • There is an ampersand in front of the input list.

Assignment Statement

The assignment statement stores 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 −

Live Demo

#include<stdio.h>
#include<stdio.h>
main(){
   int a,b,c,d;
   float avg;
   printf("Enter values for a,b,c:</p><p>");
   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

The above is the detailed content of In C language, executable statements refer to code statements that can be executed by the computer.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete