Good evening! I am a rookie in both programming and particularly in Cobra language. I would be very grateful if you answer my aks for help. Could you write me how this code will look like in Cobra?
- Task: Input an integer number n and output the sum: 1+2^2+3^2+...+n^2. Use input validation for n to be positive.
I would like to ask you to give me some clarity on this topics as well:
1. Basic Control Flow (conditional and loop statements)
2. Functions - syntax, writing and using functions, example
3. Arrays - syntax, definition, example
Just basic overlook because I'm really stuck and I have to make a review for Cobra. Sorry for bothering you and Thank you very much!
Forums
Need assitance for a task.
5 posts
• Page 1 of 1
Re: Need assitance for a task.
I'm not going to do your homework for you, but take a look at http://cobra-language.com/how-to/ to see how to write basic code as well as the tutorial. You can also look things up on the wiki and search these forums for terms like "array". You can definitely find all the answers you are looking for.
If you have a more specific question, like why some code won't compile or run as expected, feel free to share it here and ask.
If you have a more specific question, like why some code won't compile or run as expected, feel free to share it here and ask.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Need assitance for a task.
Yes, I somehow managed to run the "Hello, World!" program. I did read some of the articles in "How to". And I understand that in IT development forums users don't implement code for users like me. But actually this is not a homework or something I have as an assignment. It's part of an overview of this new and innovative language and I'm just running out of time. But I'll do my best to see it done by myself. Thank you for your response. Appreciate it.
- FiToKa
- Posts: 3
Re: Need assitance for a task.
1. Basic Control Flow (conditional and loop statements)
2. Functions - syntax, writing and using functions, example
3. Arrays - syntax, definition, example
1. Go off the Hello World for the app entry point (ie the main function).
Here's the Wiki page for Program structure: http://cobra-language.com/trac/cobra/wiki/Program
Here's the Wiki page for Conditional expressions: http://cobra-language.com/trac/cobra/wi ... tionalExpr
You'll probably want this for ensuring n is positive: http://cobra-language.com/trac/cobra/wiki/Contracts
Here's the Wiki page on Control statements (For/While loops): http://cobra-language.com/trac/cobra/wi ... Statements
2. This is a good sample for examples of function definition and usage: http://cobra-language.com/samples/WordCount/
3. Basically array syntax is equivalent to .Net, but to do an array literal (rather than List literal), you'll want to prefix it with an @. For example the first is an assignment of a list of strings to the variable d, and the latter is an array of strings
d = ["hi","bye"]
d = @["hi", "bye"]
In general the following places are very good for info:
http://cobra-language.com/samples/ (for examples)
http://cobra-language.com/trac/cobra/wiki
and in particular I use this one a lot:
http://cobra-language.com/trac/cobra/wi ... uageTopics
- torial
- Posts: 229
- Location: IA
Re: Need assitance for a task.
All this information is going to help me a lot. Thank you very much!
- FiToKa
- Posts: 3
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 61 guests