VND Openxmlformats-Officedocument Wordprocessingml Document&rendition 1-1
VND Openxmlformats-Officedocument Wordprocessingml Document&rendition 1-1
Assignment List
Remember: Lot of respect for originality; tax of marks for second-hand submissions, i.e. copied
versions. Both the enabler of copying as well as the intended beneficiary of copying will be taxed.
1. Draw a flowchart for a program which accepts three values from the user, and outputs the middle
of the three values. For example, if the values entered were to be 2, 30 and 28, then 28 is output.
2. Write one (or more) printf command(s) to print one object each of type (i) int, (ii) long int, (iii)
unsigned int, (iv) float, (v) double, (vi) char and (vii) string, (viii) a float value to be formatted with
a total width of 9 characters, 3 after the decimal point.
3. Program for Sin(x) through infinite-series expansion, taking x and sin(x) as a float objects.
[Hint: Take x in radians, not degrees.]
4. An Armstrong number (A) is one that equals the sum of its own digits, with each digit raised to the
number of digits in A. WAP that prints all Armstrong Numbers under 10000.
[Hint: 153 = 1^3 + 5^3 + 3^3]
5. Write a function (WAF) “int isLeap (int y)” that accepts the year in y, returns TRUE or FALSE.
6. Re-write the isLeap () function by combining all tests into a single expression.
7. WAF “int lcm (int x, int y)” that returns the LCM of the arguments x and y.
[Hint: do it through the gcd() function.]
8. WAF “int isPrime (int x)” that determines if argument x is a prime number or composite.
9. WAF “int isPalindrome (char s[])” that determines if argument s, a string, is a palindrome.
[Hint: Anna and Kanak are palindromes.]
10. WAF “int find (int a[], int n, int srch_val)” that searches for ‘srch_val’ within the array a, returns the
index value of the element matching srch_val or -1 if srch_val not found in the array.
11. WAF “int strMatch (char s1[], char s2[])” that receives two strings as arguments, compares the
strings, returns TRUE if they match, FALSE otherwise.
12. char *S[ ] = { “Soni”, “Toni”, “Boney”, “Moni” };
WAF char *longName (char *A[], int len) that returns a (reference to) the longest string, in this case
“Boney”.
*****