MCS-011 Problem Solving and Programming Solved Assignment 2021-22
|Course Title||Problem Solving and Programming|
|Submission Date||31st October 2021 for July 2021
15th April 2022 for January 2022
*Question 5 is not included in this solved assignment, as the question was unclear to me and I don’t want to provide the wrong solution.
- Complete Assignments
- Lowest Price
- Secure Payments
Q1: Write the following functions that:
a) Request the user for two integers and outputs them and their sum.
b) Request the user for two integers and outputs their remainder after division.
c) Request the user for two floats and outputs their product.
d) Request the user for a word and prints it twice on the same row.
Write a C (main) program to provide the above functions as options to the user using switch statement and performs the functions accordingly.
Q2: Write an algorithm, draw a corresponding flowchart and write an interactive program to convert a binary number to its decimal equivalent.
Q3: Write the following functions that:
a) Request the user to input a 5 digit number and reverse the given number and print it.
b) Request the user to input two floats and outputs the largest of the inputs.
c) Request the user to input an integer and, if the number is divisible by two, divides it by two, otherwise multiplies it by three and output the result.
d) Request the user for three integers and output whether any of them are equal. Use only
Write a C (main) program to provide the above functions as options to the user using switch statement and perform the functions accordingly.
Q4: Write a program which has 7 functions. The functions should be: main() this calls the other 6 functions namely:
fget_long() a function which returns a long data type from a file
fget_short() a function which returns a short integer variable from a file
fget_float() a function which returns a floating point variable from a file
fprt_long() a function which prints its single, long argument into a file
fprt_short() a function which prints its single, short argument into a file
fprt_float() a function which prints its single, floating point argument into a file
You should use scanf() to get the values of the variables from the input (the keyboard) and printf() to print the values to the terminal. Pay attention to using the correct format for each of the data types. If you have a compiler that only knows double, use double in
place of float – or use it anyway if you want.
Q5: Modify question 5 to use strings input from the keyboard for the input and output file names. The program should prompt for an input filename and an output filename. These names should be stored in arrays with a NULL terminating character and the array names used as arguments to the fopen() function in place of the filename constants (like “a2.c” and “a2out.c”) used in question 5.
Also prompt for and input the modes (“r” or “w”) using the same string function. Remember that, even though the ‘r’ and ‘w’ are single characters, the mode is a string with a NULL at the end.
Q6: Write an interactive C program which illustrates the following concepts:
(i) Function with no arguments and no return value.
(ii) Function with arguments and no return value.
(iii) Function with arguments and with return value.
Q7: Mention the type of applications which can be developed using C language. Also, list the latest C compilers that are available in the market by giving the details like the name of the compiler, version, vendor’s name, DOS based /WINDOWS based / Others, year of