Exforsys

Free Training

Is there Program Error

This is a discussion on Is there Program Error within the C and C++ forums, part of the Programming Talk category; Recently I and my friend came across a small C program which I have given below: #include <stdio.h> main() { ...

Go Back   Exforsys > Programming Talk > C and C++

Exforsys.com


C and C++ C and C++

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 06-22-2007, 06:15 AM
Senior Member
 
Join Date: Apr 2006
Posts: 122
rachelle is on a distinguished road
Question Is there Program Error

Recently I and my friend came across a small C program which I have given below:
#include <stdio.h>
main()
{
int test[10];
int b=5;
int a= b++ + array[b];
}

My friend told me the above program would give error. But I told the above program would work fine and the result of value b would be 6. Let us know who is correct. Will the program give error as my friend suggest? Kindly help us know about this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-24-2007, 01:32 AM
Junior Member
 
Join Date: May 2007
Posts: 12
Mukhtar Ahmad is on a distinguished road
it would give error at compile time because array is not any defined variable
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 02:27 PM
Senior Member
 
Join Date: Apr 2006
Posts: 162
sammy is on a distinguished road
I think you have by mistake made a typo error as array[b] instead of putting as test[b]. If t is test[b] in the statement as
int a= b++ + test[b];
Then you would have the value of b as 6 as you suggested. But if it is array[b] then it would give compile time error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


Similar Threads

Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 06:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 06:00 AM
Apple II Csa2 FAQs: Error List, Part 8/25 rubywand@swbell.net Tech FAQ 0 05-04-2004 09:01 AM
Linux Frequently Asked Questions with Answers (Part 6 of 6) rkiesling@mainmatter.com Tech FAQ 0 05-03-2004 06:55 AM
Apple II Csa2 FAQs: Telecom Hardware & Transfers, Part 20/25 rubywand@swbell.net Tech FAQ 0 04-04-2004 07:29 AM


All times are GMT -4. The time now is 10:07 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.