| Date related Programs |
| A Program in
C/C++ to return the day of the week given the date
|
|
|
A C/C++ Program
[Source Code] that computes the nth term of the fibonacci series and also print
the series upto the nth term.
|
A C/C++ Program
[Source Code] that reads a numbers, then coumputes and displays the factorial
of the given number
|
A C/C++ Program
[Source Code] to solve the mystery of Towers of Hanoi
|
| Array |
A C/C++ Program
[Source Code] that declares an array of size 10 that contains integers,
initialize all elements by 0 and print the contents
|
A C/C++ Program
[Source Code] that declares an array of size 10 and type int and reverse the
contents of the array.
|
A C/C++ Program
[Source Code] that reads the marks obtained of ten students out of 100 in four
papers. It computes and display the total marks and status of each student.
|
A C/C++ Program
[Source Code] to illustrate the difference b/w passing the whole array and the
single array element as a parameter to a function
|
A C/C++ Program
[Source Code] to illustrate the Bubble Sorting of arrays
|
A C/C++ Program
[Source Code] to search an element in an array using Linear search.
|
A C/C++ Program
[Source Code] to search an element in an array using Binary search.
|
A C/C++ Program
[Source Code] that reads the marks obtained of ten students out of 100. It also
computes the average, lowest and highest marks. Then shows the difference of
marks of every student from the average marks.
|
A C/C++ Program
[Source Code] to declare an 2D array of 3*4 size of type int and initialize it
by 5,10,15,... and print the contents of the array in a single line, row by row
and also display its sum.
|
A Sample Program [Source Code] in C/C++ that will display
the maximum value in the array
Download
|
A Sample Program [Source Code] in C/C++ that will compute
the average of sum of array Download
|
A Sample Program [Source Code] in C/C++ that will
insert,delete,reverse,display and search Elements of Array.
Download
|
|
A Sample Program [Source Code] in C/C++ that will Merge two Single
Dimensional Array. Download
|
A Sample in C/C++ to perform operations like addition,
multiplicaton, etc. on matrix[array]
Download
|
A Sample Program [Source Code] in C/C++ for matrix
operations like determinant, singular, etc.
Download
|
A Sample in C/C++ to Add two polynomials
Download
|
A Program [Source Code] in C/C++ to multiply two polynomials
Download
|
A Program
[Source Code] in C/C++ that Convert Number[Figure] into Word [English ] Example
192 --> one hundred and ninty two
|
A Magic
Square Program [Source Code] in C/C++. In which the sum of the row
elements and and column element are same.
|
A
Program (source code ] in C/C++ to create a 3-tuple from
a given matrix
|
A Program
(source code) in C/C++ to transpose a sparse matrix
|
A Program
(source code) in C/C++ to add two sparse matrices
|
A Program
(source code) in C/C++ to multiply two sparse matrices
|
A
Program (source code) in C/C++ to store sparse matrix as a linked list
|
A Program (Source Code) to show
the Multiplication, Addition, Subtraction, Sorting, Transpose, Searching and
Merging of two Matrices
|
Use a single-subscripted array
to solve the following problem. A company pays its salespeople on a commission
basis. The salespeople receive $200 per week plus 9 percent of their gross
sales for that week. For example, a salesperson who grosses $5000 in sales in a
week receives $200 plus 9 percent of $5000, or a total of $650. Write a program
(using an array of counters) that determines how many of the salespeople earned
salaries in each of the following ranges (assume that each salesperson’s salary
is t runcated to an integer amount):
a) $200–$299
b) $300–$399
c) $400–$499
d) $500–$599
e) $600–$699
f) $700–$799
g) $800–$899
h) $900–$999
i) $1000 and over
|
Use a single-subscripted array
to solve the following problem. Read in 20 numbers, each of which is between 10
and 100, inclusive. As each number is read, print it only if it is not a
duplicate of a number already read. Provide for the “worst case” in which all
20 numbers are different. Use the smallest possible array to solve this
problem.
|
|
Write a program that simulates the rolling of two
dice. The program should use rand to roll the first die and should use rand
again to roll the second die. The sum of the two values should then be
calculated. Note: Since each die can show an integer value from 1 to 6, then
the sum of the two values will vary from 2 to 12, with 7 being the most
frequent sum and 2 and 12 being the least frequent sums. Figure below shows the
36 possible combinations of the two dice. Your program should roll the two dice
36,000 times. Use a single-subscripted array to tally the numbers of times each
possible sum appears. Print the results in a tabular format. Also, determine if
the totals are reasonable (i.e., there are six ways to roll a 7, so
approximately one sixth of all the rolls should be 7).
| 2 |
3 |
4 |
5 |
6 |
7 |
| 3 |
4 |
5 |
6 |
7 |
8 |
| 4 |
5 |
6 |
7 |
8 |
9 |
| 5 |
6 |
7 |
8 |
9 |
10 |
| 6 |
7 |
8 |
9 |
10 |
11 |
| 7 |
8 |
9 |
10 |
11 |
12 |
|
Write a program that runs 1000
games of craps and answers the following questions:
a) How many games are won on the 1st roll, 2nd roll, …, 20th roll, and after
the 20th roll?
b) How many games are lost on the 1st roll, 2nd roll, …, 20th roll, and after
the 20th roll?
c) What are the chances of winning at craps? (Note: You should discover that
craps is one of the fairest casino games. What do you suppose this means?)
d) What is the average length of a game of craps? e) Do the chances of winning
improve with the length of the game?
|
(Airline Reservations System) A
small airline has just purchased a computer for its new automated reservations
system. You have been asked to program the new system. You are to write a
program to assign seats on each flight of the airline’s only plane (capacity:
10 seats). Your program should display the following menu of alternatives—
Please type 1 for "First Class" and Please type 2 for "Economy". If the person
types 1, your program should assign a seat in the first class section (seats
1-5). If the person types 2, your program should assign a seat in the economy
section (seats 6-10). Your program should print a boarding pass indicating the
person’s seat number and whether it is in the first class or economy section of
the plane. Use a single-subscripted array to represent the seating chart of the
plane. Initialize all the elements of the array to 0 to indicate that all seats
are empty. As each seat is assigned, set the corresponding elements of the
array to 1 to indicate that the seat is no longer available. Your program
should, of course, never assign a seat that has already been assigned. When the
first class section is full, your program should ask the person if it is
acceptable to be placed in the nonsmoking section (and vice versa). If yes,
then make the appropriate seat assignment. If no, then print the message "Next
flight leaves in 3 hours."
|
Use a double-subscripted array
to solve the following problem. A company has four salespeople (1 to 4) who
sell five different products (1 to 5). Once a day, each salesperson passes in a
slip for each different type of product sold. Each slip contains the following:
a) The salesperson number
b) The product number
c) The total dollar value of that product sold that day Thus, each salesperson
passes in between 0 and 5 sales slips per day. Assume that the information from
all of the slips for last month is available. Write a program that will read
all this information for last month’s sales and summarize the total sales by
salesperson by product. All totals should be stored in the double-subscripted
array sales. After processing all the information for last month, print the
results in tabular format with each of the columns representing a particular
salesperson and each of the rows representing a particular product. Cross total
each row to get the total sales of each product for last month; cross total
each column to get the total sales by salesperson for last month. Your tabular
printout should include these cross totals to the right of the totaled rows and
to the bottom of the totaled columns.
|
|
(Turtle Graphics) The Logo language, which is
particularly popular among personal computer users, made the concept of turtle
graphics famous. Imagine a mechanical turtle that walks around the room under
the control of a C/C++ program. The turtle holds a pen in one of two positions,
up or down. While the pen is down, the turtle traces out shapes as it moves;
while the pen is up, the turtle moves about freely without writing anything. In
this problem, you will simulate the operation of the turtle and create a
computerized sketchpad as well. Use a 20-by-20 array floor that is initialized
to zeros. Read commands from an array that contains them. Keep track of the
current position of the turtle at all times and whether the pen is currently up
or down. Assume that the turtle always starts at position 0,0 of the floor with
its pen up. The set of turtle commands your program must process are as
follows:
| Command |
Meaning |
| 1 |
Pen Up |
| 2 |
Pen Down |
| 3 |
Turn Right |
| 4 |
Turn Left |
| 5,10 |
Move forward 10 spaces (or a number other than 10) |
| 6 |
Print the 20-by-20 array |
| 7 |
End of data (sentinel |
|
(Eight Queens) Another puzzler
for chess buffs is the Eight Queens problem. Simply stated: Is it possible to
place eight queens on an empty chessboard so that no queen is “attacking” any
other, i.e., no two queens are in the same row, the same column, or along the
same diagonal? Use the thinking developed in Exercise 4.24 to formulate a
heuristic for solving the Eight Queens problem. Run your program. (Hint: It is
possible to assign a value to each square of the chessboard indicating how many
squares of an empty chessboard are “eliminated” if a queen is placed in that
square. Each of the corners would be assigned the value 22, Once these
“elimination numbers” are placed in all 64 squares, an appropriate heuristic
might be: Place the next queen in the square with the smallest elimination
number. Why is this strategy intuitively appealing? |
|
|
|