Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to programming, and I'm working in C. I know that this is structured programming but if I use blocks, say for local variables:

 int i;
 for(i=0; i<25; i++){

Doesnt this make it kind of object oriented-like? Is this still structured?

share|improve this question
up vote 0 down vote accepted

Using such code blocks does not really have anything to do with OOP. With that code you are just printing the statement 25 times.

Try looking at concrete differences between say C and Java in terms of design and application.

share|improve this answer
that helped a lot. Cheers everyone! – tapiwa 'tp' Feb 3 '12 at 23:00

One of the persistent myths about Object Oriented programming is that you need to use a special language to program in an object oriented fashion.

The truth is that you can write OO code in any language, and you can write non-OO code even in languages like C++ or Ruby that are very focused on OO.

In your example, though, the answer is no: your code is strictly procedural code.

That doesn't mean you can't write OO code in C, just that you haven't this time.

Consider for some of the background theory, and consider that the original C++ compilers were just a front-end to a C compiler.

share|improve this answer
To add to your comment, I find the concept of Abstract Data Types easier to understand initially than OOP. Of course I can't go back in time and 'unlearn' OOP, but at the time understand scoping an encapsulation in the context of OOP was very difficult. Abstract Data Types are one way to implement OOP in C and an understanding of them is very valuable, in my opinion. – Jonathan Rich Feb 3 '12 at 22:22

What you've illustrated is minimizing variable scope, which is a good thing to be doing.

You could call that a form of encapsulation, which is one of the tenets of object-oriented programming, because you're using a mechanism of the language to restrict visibility of data to only the code which needs to see it. Calling that object-oriented programming would be quite a stretch, though.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.