You are on page 1of 2

C Programming Language: Problems on Data Types, Variables, Operators-Expressions and Functions

PART A: Begin Your Journey with the Problems


1. Write an interactive program to demonstrate the process of multiplication. The program should ask the user to enter two two-digit integers and print the product shown below: Input: 45 37 45 X 37 7 X 45 is 315 3 X 45 is 1350 Adding them 1665 2. Write down a program that can take two numbers (a, b) as input and find out the addition (a+b), subtraction (a-b), multiplication (a*b) and division (a/b) of two numbers. (also do this with function calling) 3. Write down a program that can take the radius of a circle and find out its Area. (You must use the symbolic constant). (also do this with function calling) 4. Write down a program that can take the base and height of a triangle and then find out its Area. (also do this with function calling) 5. Write a program which will take seconds as input and show years, months, days, hours, minutes and seconds as output. (use long int for taking input) 6. Write a program which will take Celsius temperature as input and give Fahrenheit as output. (try some other unit conversion problems) Output

PART B: Cover This Section after Completing problems of doc-2


1. Write a program which will take 4 numbers as input from the user and return which is largest among them. Do it using functions.

2. Write a function named area to calculate the area of a triangle. The function accepts the six coordinate points (x1, y1, x2, y2, x3, y3). The function area will call another function named arms to calculate the lengths (a, b, c) of the three arms of the triangle using corresponding coordinates. Then using the values a, b, and c function area will calculate the area. 3. ***Do the problems (which can be done) in doc-2 using function calling. Such as, to check a number is prime or not, take input from the user in main function then pass the value to another function namely prime_check to check whether it is prime or not. And in case of series evolution problems, take the value of x and n (according to
Bibekananda Datta, MechE, BUET 2013 https://sites.google.com/site/bibekanandadatta

necessity) and pass them to another function name sum_up (also make functions namely power and factorial, if necessary) to evaluate the sum. In case building structure, take line number as input from the user in main function and then pass it to another function to print the structures on the computer screen. 4. ***Do the problems (which can be done) in doc-3 using function calling. Such as to add/transpose the matrix pass matrix/matrices to another function which will add them/transpose it. In case of string problems, it is preferred to build your own function without using library functions (not in all case, in most of the cases). 5. Write a program which will take number as input and find its factorial value using recursive call. 6. Use recursive call to evaluate the series in doc-2. 7. Evaluate nCr or nPr by using recursive function. 8. Write a program which will take two numbers as input and swap them by using pass by reference protocol.

Bibekananda Datta, MechE, BUET 2013 https://sites.google.com/site/bibekanandadatta