DEV Community

Cover image for In programming, the terms "line" and "statement" always mean the same thing.
jacob777baltimore
jacob777baltimore

Posted on

In programming, the terms "line" and "statement" always mean the same thing.

No, the Statement is a group of lines.
One statement contains many lines

For example:

int main()
{
    int x, y;
    printf("enter the value of x:");
    scanf("%d", &x);
    printf("enter the value of y:");
    scanf("%d", &y);
    if (x>y)
    {
           printf("x is greater than y\n");
    }
    if (x<y)
    {
           printf("x is less than y\n");
    }
    if (x==y)
    {
           printf("x is equal to y\n");
    }
    printf("End of Program");
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

The above example contains 22 lines but 3 number of Statements are three.

Line

Lines of code are the "source code" of the program, and one line may produce one machine guidance or a few relying upon the programming language. ... In an elevated level language, for example, C++ or Java, one line of code produces a progression of low-level computing construct guidelines, which brings about different machine directions.

Statements

In PC programming, a Statement is a syntactic unit of a basic programming language that communicates some activity to be done. A grouping of at least one explanation shapes a program written in such a language. An announcement may have inward part

Type of statements

Assignment statements are used to assign a program variable. Flow control explanations help direct the request where statements are performed.

There are four types of control statements

Read more

Top comments (4)

Collapse
 
dcwither profile image
Devin Witherspoon • Edited

Hey, thanks for sharing! BTW, you can tag code blocks with a language for better highlighting by adding c after your first 3 backticks .

EDIT: noticed your code was written in C, this applies to several languages though

Collapse
 
eric profile image
freePean

Greatest!

Collapse
 
jacob777baltimore profile image
jacob777baltimore

Thanks Man!!!

Collapse
 
jacob777baltimore profile image
jacob777baltimore

Thanks man!!!
I will try that.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.