Home > Backend Development > C#.Net Tutorial > How to display the value of output variable in c language

How to display the value of output variable in c language

藏色散人
Release: 2021-04-20 14:50:10
Original
19690 people have browsed it

How to display the value of the output variable in C language: First create a C language code sample file; then use printf() in C language to output multiple variable values.

How to display the value of output variable in c language

The operating environment of this article: Windows 7 system, version C11, Dell G3 computer.

C language displays the value of a variable, which is also the output variable value. In C language, you can use printf() to output multiple variable values.

Below we will introduce to you through specific code examples how to display output variable values ​​in C language.

The code example is as follows:

#include <stdio.h> 
int main()
{
    int a = 125, b = 12345;
    long ax = 1234567890;
    short s = 4043;
    float x = 2.13459;
    double dx = 1.1415927;
    char c = &#39;W&#39;;
    unsigned long ux = 2541567890;

    printf("a + c =  %d\n", a + c);
    printf("x + c = %f\n", x + c);
    printf("dx + x = %f\n", dx + x);
    printf("((int) dx) + ax =  %ld\n", ((int) dx) + ax);
    printf("a + x = %f\n", a + x);
    printf("s + b =  %d\n", s + b);
    printf("ax + b = %ld\n", ax + b);
    printf("s + c =  %hd\n", s + c);
    printf("ax + c = %ld\n", ax + c);
    printf("ax + ux = %lu\n", ax + ux);

    return 0;
}
Copy after login

The result output is as follows:

How to display the value of output variable in c language

In the above code, the specified variable is first Declaration:

int Declare the a and b variables as integer variables,

long Declare the ax variable as long integer type.

short Declare s as short integer type,

float Declare x variable as floating point type,

double declares the dx variable as a double precision real variable,

char declares the c variable as a character,

unsigned long declares the ux variable Is an unsigned long integer.

Finally, the specified variable value is output through the printf() function. The calling format of the printf() function is:

printf("<格式化字符串>", <参量表>);
Copy after login

This article is about displaying variable values ​​in c language That is, the specific method of outputting variable values ​​is introduced, which is easy to understand. I hope it will be helpful to friends in need!

The above is the detailed content of How to display the value of output variable in c language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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