FORUMS
Remove All Ads from XDA

[GUIDE]**Beginners guide to programming-C,C++,Bash,Python,java**[GUIDE]

250 posts
Thanks Meter: 1,006
 
By Dark Wraith, Senior Member on 26th December 2013, 11:59 AM
Post Reply Email Thread
29th December 2013, 03:50 PM |#31  
J-Hope's Avatar
Member
Thanks Meter: 11
 
More
Quote:
Originally Posted by N00B_IN_N33D

I'm not too sure about that.. I've never messed with C before, however, I can't imagine the logic being different than Java or C++. Assuming it is similar, your above would only execute the printf statement once.

To be exact, the integer i would be set to 0, then the condition would be checked (0 <= 50 equates to true), the printf statement would be executed and i would be incremented by 1. After that, the program would end/exit the if statement and terminate. However, had the "if" been replaced with a "while" the code would execute as desired..

Could be wrong though.

Sent from my Nexus 4 using Tapatalk

Not to be too precise or pedant, but I am pretty sure that since you inizialized i=0 the condition "i<=50" in the while would printf 51 values and not 50 (even if the last one would be 50).

ie: 0, 1, 2, 3, 4, 5....50.
29th December 2013, 06:49 PM |#32  
jatinrungta's Avatar
Senior Member
Thanks Meter: 2,322
 
More
Quote:
Originally Posted by J-Hope

Not to be too precise or pedant, but I am pretty sure that since you inizialized i=0 the condition "i<=50" in the while would printf 51 values and not 50 (even if the last one would be 50).

ie: 0, 1, 2, 3, 4, 5....50.

but since it is not a loop, it would print it only once
The Following User Says Thank You to jatinrungta For This Useful Post: [ View ] Gift jatinrungta Ad-Free
30th December 2013, 08:18 AM |#33  
Junior Member
Thanks Meter: 3
 
More
Thanks for your share!
30th December 2013, 11:25 AM |#34  
Senior Member
Thanks Meter: 784
 
Donate to Me
More
You forgot the modulo "%" math operator. Btw, lots of typo's. Many places instead of "if's" it is "i's".

Nevertheless, Good job!
30th December 2013, 11:32 AM |#35  
Dark Wraith's Avatar
OP Senior Member
Flag Bangalore
Thanks Meter: 1,006
 
Donate to Me
More
Quote:
Originally Posted by chemicalrage

You forgot the modulo "%" math operator. Btw, lots of typo's. Many places instead of "if's" it is "i's".

Nevertheless, Good job!

Thanks, the i's are not typos bro, read that portion again...by i's i mean the variable i's value...

and yeah i left out modulo operator, switch case and type casting deliberately...i was actually writing it at the moment.. Will add in some time..
30th December 2013, 11:39 AM |#36  
Senior Member
Thanks Meter: 784
 
Donate to Me
More
Quote:
Originally Posted by Dark Wraith

Thanks, the i's are not typos bro, read that portion again...by i's i mean the variable i's value...

and yeah i left out modulo operator, switch case and type casting deliberately...i was actually writing it at the moment.. Will add in some time..

Oh, my bad! Btw, are you a student or are you working somewhere?
30th December 2013, 12:28 PM |#37  
Dark Wraith's Avatar
OP Senior Member
Flag Bangalore
Thanks Meter: 1,006
 
Donate to Me
More
Quote:
Originally Posted by chemicalrage

Oh, my bad! Btw, are you a student or are you working somewhere?

No man.,,,working,..wish i was a student and i had an android phone..Would have had loads of time to spend on development
30th December 2013, 02:02 PM |#38  
Spec-Chum's Avatar
Senior Member
Thanks Meter: 90
 
More
Quote:
Originally Posted by Dark Wraith

No man.,,,working,..wish i was a student and i had an android phone..Would have had loads of time to spend on development

You and me both mate, I'd get loads more "important" stuff done if I didn't have to work instead

Nice thread BTW, I hope it really takes off and want to offer my assistance in any way I can. Just PM me if needed, but I'll check on here and try and help anyone, if that's OK?

PS
Code:
int a;
a = 'a';
is perfectly valid C/C++ and will assign the ASCII value of 'a' (97) to the integer a - it'll zero extend the 8 bit value to the 32 bit variable.
30th December 2013, 02:18 PM |#39  
Dark Wraith's Avatar
OP Senior Member
Flag Bangalore
Thanks Meter: 1,006
 
Donate to Me
More
Quote:
Originally Posted by Spec-Chum

You and me both mate, I'd get loads more "important" stuff done if I didn't have to work instead

Nice thread BTW, I hope it really takes off and want to offer my assistance in any way I can. Just PM me if needed, but I'll check on here and try and help anyone, if that's OK?

PS

Code:
int a;
a = 'a';
is perfectly valid C/C++ and will assign the ASCII value of 'a' (97) to the integer a - it'll zero extend the 8 bit value to the 32 bit variable.

thanks....
yeah adding a guide in 2 mins for type casting..hang on..
30th December 2013, 02:43 PM |#40  
Dark Wraith's Avatar
OP Senior Member
Flag Bangalore
Thanks Meter: 1,006
 
Donate to Me
More
Quote:
Originally Posted by chemicalrage

You forgot the modulo "%" math operator. Btw, lots of typo's. Many places instead of "if's" it is "i's".

Nevertheless, Good job!

Quote:
Originally Posted by Spec-Chum

You and me both mate, I'd get loads more "important" stuff done if I didn't have to work instead

Nice thread BTW, I hope it really takes off and want to offer my assistance in any way I can. Just PM me if needed, but I'll check on here and try and help anyone, if that's OK?

PS

Code:
int a;
a = 'a';
is perfectly valid C/C++ and will assign the ASCII value of 'a' (97) to the integer a - it'll zero extend the 8 bit value to the 32 bit variable.

Quote:
Originally Posted by abcdjdj

Nice work bro
Btw don't you think that it would be better to use // for comments in all the C snippets rather than # as it will confuse beginners between comments and the preprocessor (#). Also, assigning ints to chars is allowed (at least in Java you can directly assign any value between 0-65535). In C it seems that you can assign upto 255 without type casting. Also, the keyword is class and not Class and the s in string is in upper case.

Please don't get offended or anything, I have no intention of pointing out mistakes. It's just that new comers and beginners should not familiarize themselves with misconceptions. Excellent initiative bro. Keep it up





Quote:
Originally Posted by karan5chaos

"if .. else" conditions is usually taught with "switch" conditions.

switch conditions are better then nested "if..else" and "else.. if" conditions as it doesn't needs to perform all the conditions check like if..else .
u should consider including "switch" in tutorial if u can

Have updated the OP with the following

1st post

-Type Casting
-Modulus operator

2nd Post

-Changed if to conditional statement
-Added Switch Case statement
-Nesting

Lemme know if anything is wrong or needs to be added...
The Following 3 Users Say Thank You to Dark Wraith For This Useful Post: [ View ] Gift Dark Wraith Ad-Free
30th December 2013, 02:58 PM |#41  
Spec-Chum's Avatar
Senior Member
Thanks Meter: 90
 
More
Quote:
Originally Posted by Dark Wraith

Have updated the OP with the following

1st post

-Type Casting
-Modulus operator

2nd Post

-Changed if to conditional statement
-Added Switch Case statement
-Nesting

Lemme know if anything is wrong or needs to be added...

Code:
mov esi, thanksTable; lea eax, [esi+Dark_Wraith]; call eax; ret
Post Reply Subscribe to Thread

Tags
c++, java, programming guide, python, tutorial

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes