Home > Backend Development > C++ > 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
Release: 2023-08-25 14:29:16
forward
1431 people have browsed it

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);
Copy after login

For example,

printf ("average of 3 numbers = %f",avg);
Copy after login
  • printf() displays the value of its format string

scanf() function

The syntax is as follows:

scanf ("format string", input list);
Copy after login

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
Copy after login

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);
}
Copy after login

Output

You will see the following output −

Enter values for a,b,c:2 3 4
Average avg=3.000000
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template