IT Community - Software Programming, Web Development and Technical Support

What is the difference between a statement and a block?

This is a discussion on What is the difference between a statement and a block? within the C and C++ Programming forums, part of the Software Development category; Hi, Any one Explain. Thanks, Sundar Raja...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 07-20-2007, 11:37 PM
sundarraja sundarraja is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 171
sundarraja is on a distinguished road
Question What is the difference between a statement and a block?

Hi,

Any one Explain.

Thanks,
Sundar Raja
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 08-03-2007, 04:52 AM
vijayanand vijayanand is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 204
vijayanand is on a distinguished road
Default Re: What is the difference between a statement and a block?

hi sundarraj,
Statement
Statement has three types
assignment
=

selection (branching)
if (expression)
else
switch

iteration (looping)
while (expression)
for (expression;expression;expression)
do {block}

Blocks
These statements are grouped into blocks, a block is identified by curly brackets...There are two types of block.
statement blocks
if ( i == j)
{
printf("martin \n");
}

The statement block containing the printf is only executed if the i == j expression evaluates to TRUE.

function blocks
int add( int a, int b) /* Function definition */
{
int c;
c = a + b;
return c;
}
The statements in this block will only be executed if the add function is called.
__________________

J.Vijayanand
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 08-03-2007, 06:28 AM
vivekanandan vivekanandan is offline
D-Web Trainee
 
Join Date: Jul 2007
Posts: 41
vivekanandan is on a distinguished road
Default Re: What is the difference between a statement and a block?

Hi,
we can say more than one statement(except declaration) is a block, because
it is compulsory that the statement should be described in block only. default as main function block.


Regards,
Vivekanandan.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 08-10-2007, 10:15 PM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Thumbs up Re: What is the difference between a statement and a block?

An instruction or a set of instruction is called Statement,

A group of Statements grouped within a set of brace( {} ) is called Block or block of statements
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 08-10-2007, 10:18 PM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Thumbs up Re: What is the difference between a statement and a block?

one more tip about block

within a block, again we can declare variables which will be local to that block and its scope is limited to that block
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between echo and print statement? devarajan.v PHP Programming 2 07-30-2007 03:26 AM
What is TRY/CATCH block in T-SQL? oxygen Database Support 1 07-26-2007 03:19 AM
Is it necessary that each try block must be followed by a catch block? mobilegeek Java Programming 1 07-24-2007 05:44 AM
block the source code Alan HTML, CSS and Javascript Coding Techniques 5 04-23-2007 01:21 AM
difference between structured and block structured language nssukumar C and C++ Programming 0 03-03-2007 12:42 AM


All times are GMT -7. The time now is 12:41 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
Stamford Dentist | Euro Millions Lottery | Tech Support Services

SEO by vBSEO 3.0.0