Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C--
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example code== The following C-- code calculates the sum and product of integers 1 through n<ref>{{Citation | first1=Norman |last1=Ramsey |first2=Simon Peyton |last2=Jones |first3=Christian |last3=Lindig | date=2005-02-23 | title=The C-- Language Specification, version 2.0 (CVS Revision 1.128) | page=7 | url=https://www.cs.tufts.edu/~nr/c--/extern/man2.pdf | accessdate=2023-06-22 }}</ref> (n is received as an argument). It demonstrates two language features: * Procedures can return multiple results. * Tail recursion is explicitly requested with the "jump" keyword. <syntaxhighlight lang="c"> /* Tail recursion */ export sp; sp( bits32 n ) { jump sp_help( n, 1, 1 ); } sp_help( bits32 n, bits32 s, bits32 p ) { if n==1 { return( s, p ); } else { jump sp_help( n-1, s+n, p*n ); } } </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)