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 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-21-2007, 12:37 AM
sundarraja sundarraja is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 174
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
Sponsored Links
  #2 (permalink)  
Old 08-03-2007, 05:52 AM
vijayanand vijayanand is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 293
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 (permalink)  
Old 08-03-2007, 07: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 (permalink)  
Old 08-10-2007, 11: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 (permalink)  
Old 08-10-2007, 11: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 On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-c-programming/2397-what-difference-between-statement-block.html
Posted By For Type Date
DiscussWeb IT Community - Fusing This thread Refback 08-11-2007 12:36 AM

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


All times are GMT -7. The time now is 05:17 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0