Some Exercises for Students Learning C/C++ in First Year Engineering

1.     Program to Print the Message “Hello” on the Screen.
2.     Program to display a Triangle of    * on the screen.
3.     Program to calculate area of a triangle
4.     Program to evaluate the area of the circle Area = Pi * R 2
5.     Convert the time in seconds to hours, minutes and seconds. (1 hr=3600 sec).
6.     Find the sum of the digits of a four-digit number (ex 1234    sum=10).
7.     Convert temperature given in Fahrenheit to Centigrade and Centigrade to Fahrenheit. (C=5/9(F-32)).
8.     Converting distance in mm to cm, inch, feet (1 cm =10mm, 1inch=2.5cm, 1 feet =12   inches).
9.     Check whether the given number is odd or even.
10.   Find the roots of a quadratic equation (use of Switch and Break).  Hint: root = -b +/- sqrt (b2-4ac)/2a
11.   Evaluate the sin series sin x= x - x3 /3! + x5  /5! – x7 /7! + ………      Hint:  1. evaluate series till | term | <  given accuracy  evaluate to n terms
12.Generate the multiplication table for n numbers up to k terms( nested loops).
a.     Hint :     1   2   3    4   5   ….   K
   2   4   6    8   10 …..2*k
………………..
………………..
n   ………………..    nK
13.Generate prime numbers between a given limit.
14.Convert binary to decimal.
a.     Ex: 1101 = 1*2 3 + 1 * 2 2 + 0 * 2 1+ 1* 2 0 =13
15.Reverse a given number.
a.     Ex:  1234 reverse=4*10 3 +3 * 10 2 + 2 * 10 1 + 1 * 10 0 =4321
16.Find the largest and smallest element in an array.
17.Reverse the array elements using single integer array.
18.Insert an element into an array.
19.Delete an element from an array.
20.Arrange the elements of an array in ascending order by simple sorting method. (Selection sort / bubble sort)
21.Insert an element into a sorted array (new array should be sorted one).
22.Compute the row sum and column sum of a given matrix.
23.Check if the given matrix is magic square or not.
24.Find whether a given matrix is symmetric or not.
      Hint:  A = AT
25.Find the trace and norm of a given square matrix.
Hint: Trace = sum of principal diagonal elements
           Norm = sort (sum of squares of the individual elements of an array)
26.Searching for an element in the matrix and counting the number of its occurrences.
27.Count the number of words in a sentence.
28.Change all lower case letters into upper case in a sentence.
29.Reverse a string.
30.Find the sub string of a given string.
31.Concatenate two strings.
32.Check if the given string is a palindrome or not.
33.Find the factorial of a number using function.
(Ex: 5! =5*4*3*2*1. Use a function Fact to evaluate factorial & print the   result).
34.Find the maximum of a given set of numbers using functions.
a.     (Use a function Max and return the result to main function)
35.Find GCD of two numbers recursively.
a.     (Ex: GCD of 9,24 is 3)
36.Check whether the given number is prime or not. Using this function generate first n prime numbers using the above function. 
37.Write a function to generate nth Fibonacci term using recursion. Print first N Fibonacci terms using this function.
Hint: (Fibonacci series is 0, 1, 1, 2, 3, 5, 8,)
38.Write a function Sort for sorting a list of names which will use a function compare to compare two names.
a.     (Selection /bubble Sort may be used).

Comments

Popular posts from this blog

Some Problems on Three phase Circuits

Making A Sample App using Android Studio

Conceptual Questions on Interference of Waves