By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

Is C a block structured language?

Expert 100+
P: 884

First of all, I accept that this is a too simple question but I got different opinions in different books and so I'm posting it here......

The question is simple.....Is C a block structured language?

But the answers by different authors differ like a pendulum (some say YES while others say NO to this question)

For example.........

Herbert schildt in "C++-Complete reference" says-->
In your previous programming experience, you may have heard the term block-
structured applied to a computer language. Although the term block-structured
language does not strictly apply to C, C is commonly referred to simply as a
structured language. It has many similarities to other structured languages, such
as ALGOL, Pascal, and Modula-2.
The reason that C (and C++) is not, technically, a block-structured language is that
block-structured languages permit procedures or functions to be declared inside
other procedures or functions. Since C does not allow the creation of functions
within functions, it cannot formally be called block-structured.

Another book said simply----->
"C is block structured language"

My C faculty said--->
C is not block structured languges

In many other books and tutorials, I found similar answers.
So please tell me whether C is a block structured language?

THANKS in advance.........
Jul 23 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
OK. Here goes.

C is a blocked structured language.

C++ is to replace C.

Therefore, C++ is also a blocked structured language.

Now C++ does have some OO features (which you don't have to use) but even if you do, the program is still block structured. It's just that you don't need to code all of the block calls yourself like you would have to do in C.

An object-oreinted language ahs to support the Liskow Substitution Principle. This principle says a derived object can be substituted for a base object and thereafter when treated as a base object behaves like the derived object that it really is.

You cannot do this in C++. The most you can do is substitute the address of a derived objec as the address of a base object but you cannot substitute the object itself. In this sense C++ is not object-oriented.

However, the address substitution is usually enough to accomplish the same end as substituting th actual object so in that sense you can say that C++ can be object-oriented.

Please note that that a C++ program has calls made by the compiler to accomplish the object-oriented magic. Were you to have a C program, you could make those calls yourself and have an object-oriented program in C.

Note that block structured does not always mean defining procedures within procedures but also means using procedures wirthin procedures. Neither C nor C++ permits defining a procedure within a procedure but you can certainly use procedures within procedures.
Jul 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.