Bitcoin Forum
June 10, 2024, 03:37:59 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: I need some C# help  (Read 735 times)
mexxer-2 (OP)
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1005


4 Mana 7/7


View Profile
April 28, 2015, 06:43:51 PM
 #1

Hi guys,

I started learning programming in school and I got some tasks for my homework.
I solved the easier tasks, but I can't solve "harder" ones.
I hope you will give me some instructions.

Thanks Smiley

1. task
Program which writes my name 10 times.

2. task
Program which writes numbers 1-10

3. task
Program which writes numbers 0-100 and only shows even or odd numbers.
notlist3d
Legendary
*
Offline Offline

Activity: 1456
Merit: 1000



View Profile
April 28, 2015, 06:50:38 PM
 #2

You want us to do your homework?  Seriously? You made me laugh hard.

On a serious note look at your book, or online all of those are easily done.  You are starting off easy in C#.  If you don't understand the basics like this at end of semester you will be hurting very bad on keeping up.   Each lesson in programming builds on one before it.
young3dvard
Full Member
***
Offline Offline

Activity: 193
Merit: 100


View Profile
April 28, 2015, 06:51:08 PM
 #3

you need help in c? are you serious ?

Quote
1. task
Program which writes my name 10 times.

use loop . while loop preferred . sorry i will tell you other ones later i m on mobile at the moment if you say i can write whole programs for all of them Smiley

mexxer-2 (OP)
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1005


4 Mana 7/7


View Profile
April 28, 2015, 06:56:10 PM
 #4

You want us to do your homework?  Seriously? You made me laugh hard.

On a serious note look at your book, or online all of those are easily done.  You are starting off easy in C#.  If you don't understand the basics like this at end of semester you will be hurting very bad on keeping up.   Each lesson in programming builds on one before it.
I didn't ask you to do my homework. I don't want you to do it for me. I asked for instructions only
jonnybravo0311
Legendary
*
Offline Offline

Activity: 1344
Merit: 1023


Mine at Jonny's Pool


View Profile WWW
April 28, 2015, 07:17:00 PM
 #5

Hi guys,

I started learning programming in school and I got some tasks for my homework.
I solved the easier tasks, but I can't solve "harder" ones.
I hope you will give me some instructions.

Thanks Smiley

1. task
Program which writes my name 10 times.

2. task
Program which writes numbers 1-10

3. task
Program which writes numbers 0-100 and only shows even or odd numbers.
Each of these exercises requires you to understand looping constructs.  The first one asks you to repeat a task 10 times.  The second asks you to count to 10 and the third asks you to ... well, I think you wrote the third one down wrong because showing only even or odd numbers will show them all Smiley - unless you're supposed to prompt the user to enter whether or not he wishes to see evens or odds?  That seems a bit more complicated than the other two which are simply asking you to understand loops.

Loops in programming are very similar to how you'd think of repetitive tasks in your life.  For example, let's look at the first task.  How would you do it on paper (without using computer code)?

1) Look to see how many times your name has been written
2) If your name has been written fewer than 10 times, write your name
3) Repeat

You could also express this as a sentence:

I will repeatedly write my name until I have written it 10 times.

By doing this, you have given yourself a task that must be repeated until a condition is met.  Let's think of that sentence in another way:

While I have written my name fewer than 10 times, write my name.

So... you need a way to count how many times you've written your name, a way to write your name, a way to increment your counter, and a way to repeat those tasks.

We would start our counter at 0 because you haven't written your name yet.  Now, you start your repeating loop.  Is the counter less than 10?  If yes, write your name and increment the counter.  Do it again.  Now the counter is 1.  Is that less than 10?  Yup.  Write your name and increment the counter.

Now let's think of it in terms of code:

Initialize counter to 0.
While counter is less than 10:
 * Write my name
 * increment counter

I hope this helps, and allows you to follow along with your other 2 tasks.

Jonny's Pool - Mine with us and help us grow!  Support a pool that supports Bitcoin, not a hardware manufacturer's pockets!  No SPV cheats.  No empty blocks.
notlist3d
Legendary
*
Offline Offline

Activity: 1456
Merit: 1000



View Profile
April 28, 2015, 08:36:07 PM
 #6

@jonnybravo0311, you helped me a lot. Thanks

We have 2 hours of informatics weekly. Professor tells us to write some material from the books in our notebooks and when we are done, we are free.


I highly suggest buying a new book if that one is not good.  Not all books are equal on teaching programming. 

I suggest looking at Amazon.  There are some great books, that will make learning much easier if your book is crappy.
mexxer-2 (OP)
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1005


4 Mana 7/7


View Profile
April 28, 2015, 08:38:49 PM
 #7

@jonnybravo0311, you helped me a lot. Thanks

We have 2 hours of informatics weekly. Professor tells us to write some material from the books in our notebooks and when we are done, we are free.


I highly suggest buying a new book if that one is not good.  Not all books are equal on teaching programming. 

I suggest looking at Amazon.  There are some great books, that will make learning much easier if your book is crappy.
OK. I think I will do it, because I have done same thing with excel.
Thanks.
pedrog
Legendary
*
Offline Offline

Activity: 2786
Merit: 1031



View Profile
April 28, 2015, 08:47:54 PM
 #8


1. task
Program which writes my name 10 times.

#include <stdio.h>

main()

{

  int n;
  n=10;
  While (n)

    {
     printf (Your Name);
     n = n-1;
    }

}

erikalui
Legendary
*
Offline Offline

Activity: 2632
Merit: 1094



View Profile WWW
April 28, 2015, 08:49:55 PM
 #9

@jonnybravo0311, you helped me a lot. Thanks

We have 2 hours of informatics weekly. Professor tells us to write some material from the books in our notebooks and when we are done, we are free.

OK, I have done it with numbers.


Can you give me some hint how to do it with text?
 


Use a for loop instead of a do and while loop.:

for (; ; )
         {
            Console.WriteLine("Your name");
         }



1. task
Program which writes my name 10 times.

#include <stdio.h>

main()

{

  int n;
  n=10;
  While (n)

    {
     printf (Your Name);
     n = n-1;
    }

}

LOL! This is a C program and not C#.

mexxer-2 (OP)
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1005


4 Mana 7/7


View Profile
April 28, 2015, 08:56:37 PM
 #10

I forgot to mention. We need to use do while loop.
pedrog
Legendary
*
Offline Offline

Activity: 2786
Merit: 1031



View Profile
April 28, 2015, 09:04:20 PM
 #11


1. task
Program which writes my name 10 times.

#include <stdio.h>

main()

{

  int n;
  n=10;
  While (n)

    {
     printf (Your Name);
     n = n-1;
    }

}

LOL! This is a C program and not C#.

Oh, I see, I didn't even knew this exists, it's the Microsoft spin-off of C...

Sorry for wasting my time. Smiley

jonnybravo0311
Legendary
*
Offline Offline

Activity: 1344
Merit: 1023


Mine at Jonny's Pool


View Profile WWW
April 28, 2015, 09:27:17 PM
Last edit: April 28, 2015, 10:13:48 PM by jonnybravo0311
 #12

@jonnybravo0311, you helped me a lot. Thanks

We have 2 hours of informatics weekly. Professor tells us to write some material from the books in our notebooks and when we are done, we are free.

OK, I have done it with numbers.
http://img.prntscr.com/img?url=https://i.imgur.com/xtFIDIX.png

Can you give me some hint how to do it with text?
 
http://img.prntscr.com/img?url=https://i.imgur.com/zuLSoPJ.png
The text one will be very similar.  Instead of printing out your counter variable, you just print the text over and over again.

Code:
int i = 0;
do {
  Console.WriteLine("jonnybravo0311");
  i++;
}
while (i < 10);

You'll have to explain the third task a bit more clearly.  Are you supposed to prompt the user to actually tell you whether to show odds or evens?  Or are you just supposed to count to 100 by odds first, and evens second?

Think about that third task and try to put it into terms like I did for your first task.  How do you count only the odds, or only the evens in your head?  How would you do it on paper?

Jonny's Pool - Mine with us and help us grow!  Support a pool that supports Bitcoin, not a hardware manufacturer's pockets!  No SPV cheats.  No empty blocks.
notlist3d
Legendary
*
Offline Offline

Activity: 1456
Merit: 1000



View Profile
April 28, 2015, 10:10:14 PM
 #13

One thing I might suggest is comparing code to what instructor used.   In programming there are ton's of ways to solve a solution.  But if everyone uses about the same code shown in class and you use different it will bring up questions.

Also are you allowed to use laptops during class?   If you are I suggest bringing one and trying to write the programs as instructor does.   That helped me alot then I had a version to compare to.
Lethn
Legendary
*
Offline Offline

Activity: 1540
Merit: 1000



View Profile WWW
May 05, 2015, 03:08:53 PM
 #14

Be sure to get this book if you're serious about programming: http://www.amazon.com/Primer-5th-Edition-Stanley-Lippman/dp/0321714113

Even though it's C++ it's got tons of information and glossaries about all the programming vocubulary etc. you need and there are free .pdfs around on the internet if you really want it. I particularly recommend this one just because it explains all sorts of terms to you in actual English so you can have a conversation with other programmers and not feel completely lost.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!