United International University
Dept. of Computer Science & Engineering
Structured Programming Language Sessional
Course Code CSI 122
Fall-2013
Assignment-03
Solve all the problems using C language.
Print the following pattern based on input n.
1. For n = 4
Output:
1_____1
12___21
123_321
1234321
2. For n = 5 (only odd inputs)
Output:
*****
*___*
*****
*___*
*****
3. For n = 5
Output:
10101
01010
10101
01010
10101
4. Print the following pattern based on value of n.
When n = 5
When n = 7
When n = 9
*___*
_*_*_
__*__
_*_*_
*___*
*_____*
_*___*_
__*_*__
___*___
__*_*__
_*___*_
*_____*
*_______*
_*_____*_
__*___*__
___*_*___
____*____
___*_*___
__*___*__
_*_____*_
*_______*
Page 1 of 2
5. Print the following pattern based on value of n.
When n = 9
When n = 13
When n = 17
____$____
___$$$___
__$_$_$__
_$__$__$_
$$$$$$$$$
_$__$__$_
__$_$_$__
___$$$___
____$____
______$______
_____$$$_____
____$_$_$____
___$__$__$___
__$___$___$__
_$____$____$_
$$$$$$$$$$$$$
_$____$____$_
__$___$___$__
___$__$__$___
____$_$_$____
_____$$$_____
______$______
________$________
_______$$$_______
______$_$_$______
_____$__$__$_____
____$___$___$____
___$____$____$___
__$_____$_____$__
_$______$______$_
$$$$$$$$$$$$$$$$$
_$______$______$_
__$_____$_____$__
___$____$____$___
____$___$___$____
_____$__$__$_____
______$_$_$______
_______$$$_______
________$________
6. Print the following pattern based on value of n.
When n = 2
When n = 3
When n = 4
*
**
__*
__**
*
**
***
___*
___**
___***
______*
______**
______***
*
**
***
****
____*
____**
____***
____****
________*
________**
________***
________****
____________*
____________**
____________***
____________****
Page 2 of 2