The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Separating if and else blocks in C
Discuss Separating if and else blocks in C in the Python Programming forum on Dev Shed. Separating if and else blocks in C Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 6th, 2012, 05:42 PM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 4
Time spent in forums: 40 m 48 sec
Reputation Power: 0
|
|
|
Separating if and else blocks in C
So I'm trying to understand how C manages to decide which code is part of which block?
For instance, here is a part of my code:
Code:
if (circle[i].radius<0)
circle[i].area = 0;
else
circle[i].area = process(circle[i].radius);
printf("\nIdentifier: ");
scanf("%s",circle[++i].text);
Will the printf and scanf be a part of the else-block? Or will they be considered separate from the else-blok due to the indent? If the answer is yes, then how can I make it so that they are distinct from the else-block? Do I use braces?
Does indentation matter at all in C? If you use braces consistently, then will indentation matter in the context of recognizing if and else blocks?
What about for while and for loops?
Thanks and appreciate all help !!!
EDIT: Sorry, I just realized this was a Pythno forum. Could a moderator please move it to the C forum?
BiP
|

August 6th, 2012, 08:54 PM
|
 |
Contributing User
|
|
|
|
White space in c source delimits tokens, and that's all.
Guess the effect of this program then try it.
Code:
#include <stdio.h>
main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \
}'+}##(!!/")
:t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
:0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
(I didn't test it.)
Consider the differences between
--x versus - -x
or
x&&y versus x& &y
And perhaps you who learned the c trigraphs can think of other hideous examples.
The c preprocessor requires that # start in column 1.
__________________
[code] Code tags[/code] are essential for python code!
Last edited by b49P23TIvg : August 6th, 2012 at 08:57 PM.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|