Question: I am trying to add a UIImageView object to a UIScrollView.

```
FVImageSequence *imageSquence;
[imageSquence setImage:[UIImage imageNamed: @"car_0.jpg"]];
[scroll addSubview:imageSquence];
scroll.userInteractionEnabled=YES;

```

The imageSequence is an object of FVImageSequence class which inherits UIImageView 

```
@interface FVImageSequence : UIImageView {
NSString *prefix;
int numberOfImages;
int current;
int previous;
NSString *extension;
int increment;
}

```

But when i run the code it is crashing.When i used a direct UIImageView object,it works fine.How can i fix this?

```
UIImageView *imageSquence;
[imageSquence setImage:[UIImage imageNamed: @"car_0.jpg"]];
[scroll addSubview:imageSquence];
scroll.userInteractionEnabled=YES;

```

This code runs fine.What is the problem with the first one?

Answer: 
Instead of

```
for(int j=1;j<=num;j++){
     System.out.print(num);
}

```

I think you need to print either a `1` or a `0` (according to your example). So you should compute whether `num` is even or odd, and decide whether to print `0` or `1`. For example

```
for(int j=1;j<=num;j++){
     System.out.print(1 - num%2);
}

```

Because `num%2 = 0` when num is even, and 1 if it is odd - and it seems you want the opposite. So `1 - num%2` should give you what you need.

Before:

```
Enter a number 
6
666666
55555
4444
333
22
1

```

After:

```
Enter a number 
6
111111
00000
1111
000
11
0

```
Change you code like this :

```
boolean flag = false;
         while(num > 0){
                 flag = !flag;
                 for(int j=1;j<=num;j++){
                 if(flag==true)
                 System.out.print("1");
                 else
                     System.out.print("0");

                }

                System.out.print("\n");

                num--;

         }

```