Q1. Write an algorithm, draw a corresponding flowchart and write an interactive program to convert a decimal number to its hexadecimal equivalent.
Answer : -
Algorithm
- Input decimal number
- Divide the decimal number by 16 and write down the remainder in Hexadecimal format in a character array.
- Divide the decimal number again by 16. [Treat the division as an integer division.]
- Repeat step 2 and 3 until decimal number is 0.
- Print the Hexadecimal values present in the character array from last to first.
Flowchart
Programming
#include<stdio.h> int main() Output : |
Q2. Write a interactive C program to find the MINIMUM and MAXIMUM (value) array elements in a given 3X3 matrix.
Answer : -
#include<stdio.h> int main() Output : |
Q3. Write the following functions that :
- Calculate simple interest.
- Calculate compound interest.
Write a C (main) program to provide the above functions as options to the user using switch statement and performs the functions accordingly.
Answer : -
#include<stdio.h> #include<math.h> int main() Output 1 : Output 2 : |
Q4. Write the following string functions that :
- Replace a character in a given string with a character suggested by the user.
- Convert the given string into uppercase.
- Convert the alternate character into upper case.
- Check each and every character in the string and display whether it is an alphabet, digit or special character.
Write a C (main) program to provide the above string functions as options to the user using switch statement and perform the functions accordingly.
Answer : -
#include<stdio.h> #include<string.h> #include<ctype.h> int main() Output 1 : Output 2 : Output 3 : Output 4 :
|
Q5. Write a program to search a given string among the available strings, using Binary Search.
Answer : -
#include<stdio.h> #include<string.h> int main() Output 1 : Output 2 : |
Q6. Using structures concept in C programming, write a program to calculate the daily wages for each worker (if 7 workers are employed in an iron and hardware shop) at an hourly basis of Rs.100/- (with a constraint that each worker may be allowed maximum upto 4 hours only per day). It should display the name of the worker, date and total wages for that day.
Answer : -
#include<stdio.h> #include<string.h> /* Structure Declaration */ int main() Output : |
Q7. Using pointers, find the sum of all the elements of a 3X3 matrix.
Answer : -
#include<stdio.h> int main() Output : |
Q8. Using file handling, write a C program :
a) To generate 10 records for MCA 1st semester students and store them in stu.dat along with appropriate fields.
Answer : -
#include<stdio.h> #include<string.h> struct result struct student int main() Output : |
b) To read the data from the file stu.dat (created above) and compute the total marks and average marks and display the grade(assumptions can be made).
Answer : -
#include<stdio.h> struct result struct student int main() Output : |