TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C Tutorials

C Expressions

Overview

In this tutorial, we will learn about C Expressions. An expression is a combination of operands, operators, and function calls that resolves or reduces to a single value.

C Expressions

Expressions can be broadly classified into two categories:

  • Simple Expressions
  • Complex Expressions

Simple Expressions

Simple expressions can be categorized into different types. The expression categories are as follows:

  • Primary
  • Prefix
  • Postfix
  • Unary
  • Binary
  • Ternary

Example

In this example, a and b are operands. The * is an operator. The operator is a multiplication operator that calculates the product of two values. The * operator is a binary operator. It requires two operands for the expression.

The result on the right-hand side (RHS) is a variable. The value of the expression is computed and stored in the variable result.

result = a * b;

C Expression

If the operand values are:

a = 3;

b = 5;

In this example, a * b is an expression. When calculated it reduces to the value 15.

Code

/**
**********************************
* Program Description:
* C Expressions Demo
* Filename: expr.c
* C Tutorials - www.TestingDocs.com
*************************************
*/
#include<stdio.h>
int main()
{
 // declare variables
 int a = 3;
 int b = 5;
 int result = 0;

 /* Simple expression */
 result = a * b;

 printf("Result = %d \n",result);
 /* Complex expression */

 return 0;
} // end main

C Expressions

Complex Expressions

Complex expressions are expressions formed by one or more simple expressions.

—

C Tutorials

C Tutorials on this website can be found at:

https://www.testingdocs.com/c-language-tutorial/

Related Posts

C Language Characteristics

C Tutorials /

C Language Characteristics

C Source Code .c File

C Tutorials /

C Program Files & Formats

GNU Compiler Collection GCC

C Tutorials /

C Compilers

C Pointers

C Tutorials /

C Pointers

C Tutorials /

C Two-Dimensional Arrays

‹ C Global Variables› C Case-Sensitive Programming Language

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com