C Important
C Important
In this program, we will learn how to add two distances in feet and inches using structure
in C programming language?
This example has a structure named distance with two integer members feet and inches,
we are implementing a user define function named addDistance() that will take two
structure objects and print sum (addition) of their elements.
Test Case:
Output:
Enter first distance in feet & inches: 10 8
Enter second distance in feet & inches: 5 7
Total distance- Feet: 16, Inches: 3
2. Write a program in C to check a given number is even or odd using the function.
Test Case:
Input:
5
Output:
The entered number is odd.
3. Write a C program to swap two float numbers using user defined function with function
name swap.
Input
Numbers before swaping : a=2,b=6
Output
Numbers after swaping: a=6,b=2
4. Write a C programming to find out maximum and minimum of some values using
function which will return an array.
Test Case:
Input:
Enter 5 array elements:
34
23
78
89
56
Output:
The smallest number is: 24
5. Write C program to create, declare and initialize structure,
In this program, we will learn how to declare a structure with different types of
variables, declare and initialization of structure variable? Here we are not reading values
from keyboard; we are assigning the values to the structure members at the time of
structure variable declaration.
Test Case:
Output:
Name: Mike
Id: 1120
Salary: 76909.000000
6. A person have the difficulty to concatenate his/her name with father name, write a C
program to help them to concatenate the person name and father name using the user
defined function. [Hint: Also use string manipulation function]
Test Case
Input
Person name : SIVA
Father name :KARTHIKEYAN
Output
Final name : SIVAKARTHIKEYAN
7. Design a C program for passing structures as function arguments and returning a structure
from a function,We can have a function of type returning a structure or a pointer to it,
below code shows how to operate when we have a function taking structure as an
argument:
Test Case:
Output:
Enter a number: 10
Enter a number again: 20
30
8. Write a C program to create a structure STUDENT with data members reading a
student’s test marks [Atleast 3 subjects]. Read the test marks for 2 students and find total
for each student.
9. Yasir is a very active young man who is very interested in making money in a simple
way. So he is always looking for a way to make some money. One day, a money-making
show called Jackpot on popular channel news came to Yasir's ears. So he was going to
the JACKPOT game in a game park it has a dial full of numbers in random order. If it is
arranged in ascending order using the sorting concept, he will win a million-dollar prize.
can you help him to input an array of size n and sort it in ascending order using the
sorting?
Constraints: 1≤n≤1000 1≤array≤1000
Test Case:
Input:
First-line represents the number of values Second-line indicates the random integer
numbers.
Output:
In a single-line of output print the values in ascending order.
10. Create a structure ACCOUNT with data members for reading account details of 3
customers. Write a program to get data and print the same.
Test Case
Input
102
ABI
10000
104
BALA
5800
108
RAVI
7850
Output
102
ABI
10000
104
BALA
5800
108
RAVI
7850
11. Write a C program to find the area of the square, rectangle, and circle using functions.
[Get the sides of the square and rectangle, radius of the circle as input and pass them as
argument to the called function].
12. Write a C program to add two numbers using Functions. [ Implement 4 function
categorization]
13. Write a C program to create a structure STUDENT with data members reading a
student’s test marks [Atleast 3 subjects]. Read the test marks for 5 students and print the
name of student who got highest mark in subject 1
14. To demonstrate C program example structure pointer (structure with pointer) using user
define function
Test Case:
Output :
In a Single line print the sum of array elements Enter product name: Pen
Enter price:5.50
Enter quantity: 15
Name: Pen
Price: 5.500000
Quantity: 15
Total Amount: 82.500000
15. Write a C programming to find out maximum and minimum of some values using
function which will return an array.
Test Case:
Input:
25
11
35
65
20
Output:
Number of values you want to input: Input 5 values
Minimum value is: 11
Maximum value is: 65
16. Write a C program to find the factorial of a number using recursive function
Input
5
Output
Factorial of the number 5 is 120
17. Define a structure EMPLOYEE which defines empid, empname, dob, salary. Write a C
program to get details of an employee and print the salary receipt
Note: For dob, use nested structure [dob – dd, mm, yy].
18. Define a structure BOOK which has bno, bname, aname, price. Give a C program to find
the Book name whose price is above 800. Consider a structure of BOOK with details of
at least 5 books.
19. Nancy, Simon, and Swati were all attending campus interviews. they got selected
for the second round. Nancy failed to clear the second round and others to
selected for the next round of interviews.Nancy discussed with her friend the
question which came in the interview.one of the questions was, to create a
program for the Fibonacci series. Nanc e doesn't know, how to solveit.But it's in
the syllabus of his exam. So can you help to create a program in the specified
concept to get an offer in the next interview ?.(using recursion)
20. Tina is a Bachelor of Computer Applications (BCA) student. During her final
year Campus Interview, she has an opportunity to get a job in a software
company in Bangalore. The company provides Five months training period with
Rs.30000/month Package. Then it will be incremented to Rs.55000 per month. At
the end of the training, the examination was conducted for all freshers, Tina got
a question paper and one of the questions comes under the concept of
programming. The program was, she has to calculate the sum of an array of
elements using RECURSION to Complete One of Her math Problem. Tina does
not know how to get the output for this program using recursion. So you have to
help Tina get this job.