Sei sulla pagina 1di 1

1.

W.A.P which performs Addition, Subtraction and Multiplication of matrices. The d


imensions of both the matrices would be specifiedby the user.
2.
W.A.P in C to SWAP the contents of 3 variables without using the temporary (or e
xtra) variables.
3.
W.A.P. in C to find the Fifth root of the sum of the squares of the first 100 OD
D numbers only.
4.
W.A.P. in C to multiply any two numbers without using * (asterisk) [Hint : Use B
ITWISE OPERATORS]
5.
W.A.P. in C to check whether given number x is equal to the value 2 POWER i or s
omething. [Hint: where i>=0 using BITWISEoperators ONLY.]
6.

W.A.P. in C that acts as a guessing game in which the user has eight tries to gu
ess a randomly generated number within 100. Theprogram will tell the user each t
ime whether he guessed high or low. The user WINS the game when the number guess
ed is same asrandomly generated number.
7.
W.A.P. to determine how much money is in a piggy bank that contains several 50 p
aise coins, 25 paise coins, 20 paise coins, 10 paisecoins and 5 paise coins. Use
the following values to test your program : Five 50 paise coins, Three 25 paise
coins, Two 20 paise coins,One 10 paise coin and Fifteen 5 paise coins. (Answer
: Rs. 4.50)
8.
W.A.P. in C to determine how many of the characters are vowels and how many are
consonants in a given line of text. Also terminatethe string when the input char
acter encountered is other than the alphabets(a-z or A-Z) and Blank spaces.[Hint
:(a) When the input string is 'C FOR SWIMMERS, TEST YOUR C PROGRAMMING STRENGTHS
'. Consider the string 'C FORSWIMMERS' only Because ',' is encountered. (b) When
the input string is 'Y2K PROBLEM'. Consider the character 'Y' only Becausethe '
2' is encountered.]
9.

Write a program to play a game of marbles. The game starts with 32 marbles and t
wo players. Each player must take 1, 2 or 3 marbleson their turn. Turns go back
and forth between the two players. The winner is the person who takes the last m
arble. Your programshould prompt each player with a message that states the curr
ent number of marbles and asks them how many they'd like to take.Continue until
there is a winner. Then your program should print out the winner (either player
#1 or player #2.) (Incidentally, if bothplayers play optimally, who always wins?
What is their strategy?)
10.
Write a function that takes in the coefficients a (not 0), b, and c (all doubles
) to a quadratic equation and returns the smaller of the tworoots (a double) as
the result. You may assume that the roots of the quadratic are real. The formula
for the roots of a quadratic is given below
x=-b+-root(b*b-4ac)/2a

Potrebbero piacerti anche