# Challenge 1 ( the beginners way)

## Replies

 c student · February 8, 2015 and what if the spec was changed to a length greater than 4?one of the main things a computer is fantastic at is repetition and the ability to be scalable, all aspects which are not present in this, however, since you are a beginner, it's fine... for now.  even i remember doing something as incredibly horrifying like this.things to note:your input only takes strings up to 4 characters (4 to store the string and the last element to store the string terminator),notice patterns in your code.  anything with patterns can be set into combinations of loops and conditional statements. for example, a simple program to sum up the simple pattern: 1+2+3+..+10:``int i, sum = 0;for (i = 1; i < 11; i++) {    sum += i;    // 0+1, 1+2, 3+3, 6+4, ..., 45+10 = 55}`` H. P. Lovecraft · February 8, 2015 Hi, this is certainly one way to solve it, but not the best. It works, but like c student said, it can't handle passwords longer than 4 characters, but you made one mistake. You are checking at position 5, remember with arrays we start counting at 0. So for an array of 5 chars, you have position 0, 1, 2, 3, 4. You are checking at a 5th position, this can cause your program to randomly crash and do weird stuff. J show · February 8, 2015 I actually just learned that it starts at zero last week. ha and we just learned the while and for loop as well. I'm also taking matlab this semester so hopefully the two dont screw me up to much haha Shahriar Khan · February 9, 2015 Mathias Frits Rørvik . you are right. the character string named password should be [6].
• 1

## C

120,857 followers