際際滷

際際滷Share a Scribd company logo
CSC-141 Introduction to Computer Programming Spring-2013
Assignment 2
CSC-141 Introduction to Computer Programming
Instructor: Saba Anwar
Class: FA12-BPH-A
Total Marks: 50
Assignment Date Saturday May 18, 2013
Submission Date and Time: Monday May 25, 2013 by 11:55 PM
Submission Guidelines:
This is an individual assignment. For collaboration rules, please consult academic rules /honor code
(placed at website).Your submitted work will be compared with that of your friends, and copied work will
lead you to strict penalty.
When you are done with both questions, place your name and roll number in comments at start of each
program. Save each file with filename of this pattern: FA12BPH-0XX-1.c and FA12-0XX-2.c. XX is your
ID and 1, 2 represent Task number.
Send both files in a single mail with subject FA12-BPH-A [Assignment1] to
ciitsubmissions@gmail.com
Any violation may misplace your assignment and you will be marked as Absent in assignment.
You may submit it late as well. 20% marks will be deducted for late submission of one day and 40%
marks will be deducted for late submission of two days. No assignment will be accepted after 48 hours.
__________________________________________________________________________________
Task 1
A possible 2D array is given below
You can see that its last cell is empty. Implement the following program:
Numbers should be displayed in the above fashion. Allow the user to hit any of the arrow
keys (up, down, left or right). If user hits up key, then the piece with number 4 and blank
piece will be swapped, and this table will look like:
CSC-141 Introduction to Computer Programming Spring-2013
After that if user hits left key, then the piece with number 43 and blank piece will be swapped
and table will look like:
If user hits left key and there is no column on left, then it should give appropriate message. With every
hit, it will check whether numbers are sorted in ascending order or not. When all 15 integers are sorted
and blank is at last position, then it should stop by giving success message, and this table will look like:
To keep track of keys, use getch() and identify each key by its ASCII codes as follows:
 Up arrow key: 72
 Down arrow key: 80
 Right arrow key: 75
 Left arrow key: 77
It should also show number of moves at each step. It may also be stopped by press q somewhere to
quit the program.
Task 2
CSC-141 Introduction to Computer Programming Spring-2013
In this task you will be implementing a simple board game called Dungeon Crawl. It will use a simple 2D
string array to draw the game board. The board should be like following:
 P 
 E 
 E 
 E 
 E 
 E 
 $
P is the player, Es are enemies, and $ is the treasure. Objective of the game is to safely steal the hidden
treasure in the dungeon. Following are the rules of game
1. P can move in any direction but it should not go beyond the board boundary, if it goes he dies
and game will be lost.
2. If P collides with any enemy, its life points are decreased by 1. The total points are 3 at start.
Display life points along with board throughout the game.
3. Enemies can be placed anywhere on board randomly, every time game starts, But players
position can be fixed in 1st
row where ever you want. You can set number of enemies yourself,
but minimum they should be 5
Use arrows keys to move the player on board
Bonus point: you can move enemies in random directions with every move of player.
___________________________________________
Ad

Recommended

trabajo
elianny22
Duty to english
Duty to english
tatititazx75
Dewan Perwakilan Rakyat Bermutu
Dewan Perwakilan Rakyat Bermutu
Emzet Juwitour
Kti tri wahyuni
Kti tri wahyuni
Karya Tulis Ilmiah
2015-07 Te Kura Whenua
2015-07 Te Kura Whenua
Fiona Coyle
犢犖犖犢犖犖犖÷犢犖犢犖犖犖犖萎犖犖犖犖犖
犢犖犖犢犖犖犖÷犢犖犢犖犖犖犖萎犖犖犖犖犖
Wanvipa TOey
B slim
B slim
Meow Gochkorn
Il Parlamento Europeo
Il Parlamento Europeo
lucamaserati
Amcat automata questions
Amcat automata questions
ESWARANM92
Amcat automata questions
Amcat automata questions
ESWARANM92
Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointers
enidcruz
Educational courses/tutorialoutlet.com
Educational courses/tutorialoutlet.com
Crookstonz
1 CS110 - Introduction to Computers and Applications .docx
1 CS110 - Introduction to Computers and Applications .docx
honey725342
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
MES LAB MANUAL for engineering students.
MES LAB MANUAL for engineering students.
GautamDematti1
Western Oregon University Page 1 of 2 CS-161.docx
Western Oregon University Page 1 of 2 CS-161.docx
aryan532920
C++ programming exercise
C++ programming exercise
khapul
efy-articles
efy-articles
Lokesh Kumar
Cse cpl manual-2016
Cse cpl manual-2016
Rajendra khatana
DeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latest
Atifkhilji
Arduino coding class
Arduino coding class
Jonah Marrs
ARM lab programs
ARM lab programs
revanasidha janbgi
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_ii
Elsayed Hemayed
Lec03-CS110 Computational Engineering
Lec03-CS110 Computational Engineering
Sri Harsha Pamu
Home works summary.pptx
Home works summary.pptx
HebaEng
C++ Programming (Please help me!! Thank you!!)Problem A Win SimU.pdf
C++ Programming (Please help me!! Thank you!!)Problem A Win SimU.pdf
aromalcom
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
Bca(rev syll ii-sem) assignment for july 2012 and jan 2013 sessionn
Bca(rev syll ii-sem) assignment for july 2012 and jan 2013 sessionn
Shripad Tawade

More Related Content

Similar to Assignment 2 (20)

Amcat automata questions
Amcat automata questions
ESWARANM92
Amcat automata questions
Amcat automata questions
ESWARANM92
Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointers
enidcruz
Educational courses/tutorialoutlet.com
Educational courses/tutorialoutlet.com
Crookstonz
1 CS110 - Introduction to Computers and Applications .docx
1 CS110 - Introduction to Computers and Applications .docx
honey725342
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
MES LAB MANUAL for engineering students.
MES LAB MANUAL for engineering students.
GautamDematti1
Western Oregon University Page 1 of 2 CS-161.docx
Western Oregon University Page 1 of 2 CS-161.docx
aryan532920
C++ programming exercise
C++ programming exercise
khapul
efy-articles
efy-articles
Lokesh Kumar
Cse cpl manual-2016
Cse cpl manual-2016
Rajendra khatana
DeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latest
Atifkhilji
Arduino coding class
Arduino coding class
Jonah Marrs
ARM lab programs
ARM lab programs
revanasidha janbgi
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_ii
Elsayed Hemayed
Lec03-CS110 Computational Engineering
Lec03-CS110 Computational Engineering
Sri Harsha Pamu
Home works summary.pptx
Home works summary.pptx
HebaEng
C++ Programming (Please help me!! Thank you!!)Problem A Win SimU.pdf
C++ Programming (Please help me!! Thank you!!)Problem A Win SimU.pdf
aromalcom
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
Bca(rev syll ii-sem) assignment for july 2012 and jan 2013 sessionn
Bca(rev syll ii-sem) assignment for july 2012 and jan 2013 sessionn
Shripad Tawade
Amcat automata questions
Amcat automata questions
ESWARANM92
Amcat automata questions
Amcat automata questions
ESWARANM92
Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointers
enidcruz
Educational courses/tutorialoutlet.com
Educational courses/tutorialoutlet.com
Crookstonz
1 CS110 - Introduction to Computers and Applications .docx
1 CS110 - Introduction to Computers and Applications .docx
honey725342
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
MES LAB MANUAL for engineering students.
MES LAB MANUAL for engineering students.
GautamDematti1
Western Oregon University Page 1 of 2 CS-161.docx
Western Oregon University Page 1 of 2 CS-161.docx
aryan532920
C++ programming exercise
C++ programming exercise
khapul
DeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latest
Atifkhilji
Arduino coding class
Arduino coding class
Jonah Marrs
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_ii
Elsayed Hemayed
Lec03-CS110 Computational Engineering
Lec03-CS110 Computational Engineering
Sri Harsha Pamu
Home works summary.pptx
Home works summary.pptx
HebaEng
C++ Programming (Please help me!! Thank you!!)Problem A Win SimU.pdf
C++ Programming (Please help me!! Thank you!!)Problem A Win SimU.pdf
aromalcom
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
Bca(rev syll ii-sem) assignment for july 2012 and jan 2013 sessionn
Bca(rev syll ii-sem) assignment for july 2012 and jan 2013 sessionn
Shripad Tawade

Assignment 2

  • 1. CSC-141 Introduction to Computer Programming Spring-2013 Assignment 2 CSC-141 Introduction to Computer Programming Instructor: Saba Anwar Class: FA12-BPH-A Total Marks: 50 Assignment Date Saturday May 18, 2013 Submission Date and Time: Monday May 25, 2013 by 11:55 PM Submission Guidelines: This is an individual assignment. For collaboration rules, please consult academic rules /honor code (placed at website).Your submitted work will be compared with that of your friends, and copied work will lead you to strict penalty. When you are done with both questions, place your name and roll number in comments at start of each program. Save each file with filename of this pattern: FA12BPH-0XX-1.c and FA12-0XX-2.c. XX is your ID and 1, 2 represent Task number. Send both files in a single mail with subject FA12-BPH-A [Assignment1] to ciitsubmissions@gmail.com Any violation may misplace your assignment and you will be marked as Absent in assignment. You may submit it late as well. 20% marks will be deducted for late submission of one day and 40% marks will be deducted for late submission of two days. No assignment will be accepted after 48 hours. __________________________________________________________________________________ Task 1 A possible 2D array is given below You can see that its last cell is empty. Implement the following program: Numbers should be displayed in the above fashion. Allow the user to hit any of the arrow keys (up, down, left or right). If user hits up key, then the piece with number 4 and blank piece will be swapped, and this table will look like:
  • 2. CSC-141 Introduction to Computer Programming Spring-2013 After that if user hits left key, then the piece with number 43 and blank piece will be swapped and table will look like: If user hits left key and there is no column on left, then it should give appropriate message. With every hit, it will check whether numbers are sorted in ascending order or not. When all 15 integers are sorted and blank is at last position, then it should stop by giving success message, and this table will look like: To keep track of keys, use getch() and identify each key by its ASCII codes as follows: Up arrow key: 72 Down arrow key: 80 Right arrow key: 75 Left arrow key: 77 It should also show number of moves at each step. It may also be stopped by press q somewhere to quit the program. Task 2
  • 3. CSC-141 Introduction to Computer Programming Spring-2013 In this task you will be implementing a simple board game called Dungeon Crawl. It will use a simple 2D string array to draw the game board. The board should be like following: P E E E E E $ P is the player, Es are enemies, and $ is the treasure. Objective of the game is to safely steal the hidden treasure in the dungeon. Following are the rules of game 1. P can move in any direction but it should not go beyond the board boundary, if it goes he dies and game will be lost. 2. If P collides with any enemy, its life points are decreased by 1. The total points are 3 at start. Display life points along with board throughout the game. 3. Enemies can be placed anywhere on board randomly, every time game starts, But players position can be fixed in 1st row where ever you want. You can set number of enemies yourself, but minimum they should be 5 Use arrows keys to move the player on board Bonus point: you can move enemies in random directions with every move of player. ___________________________________________