Assignment Questions
Assignment Questions
ASSIGNMENT
1. Write a program to print the sum of diagonal elements of an array and which are divisible
by 3 in a given 3 X 3 matrix.
3 9 1
x[3][3] = 0 0 0
9 3 5
2. Write a program to search an element in one dimensional array. If the element is present in
the array print as “ELEMENT FOUND” else “ELEMENT NOT FOUND” Only once.
3. State the purpose of array. Illustrate the possible ways of array initialization and accessing
array elements for one dimensional and two dimensional integer arrays.
4. Write a program to get 5 elements as input for one dimensional array A and insert an
element 1000 in the location A[2].
5. Neena opens her piggybank every year on January 1st and she counts her savings amount
and noted with denominations as shown below.
Year Till Rs.500 Rs.200 Rs.100 Rs.50
2022 16 7 18 32
2021 15 9 23 10
2020 10 13 19 12
2019 05 14 23 46
Write a program to do the following task
i) Display the cumulative amount in piggybank
ii) Total number of 500 rupee currencies available in the piggy bank
6. What is recursion? Write a program to get the N value from the user and find the Fibonacci
series using recursion.
Sample Input: Enter the N value to generate the series: 13
Expected Output: 0 1 1 2 3 5 8 13
7. Discuss the terms storage, initial value, scope and life time of the variable associated with
storage class? Explain the different types of storage class supported by C with appropriate
examples.
8. Mention the different ways to initialize string “C PROGRAMMING ”. Write a program
to using the following string functions. (i) strcmp() (ii) strcpy() (iii) strrev()
1
9. Describe the components of the function. Write a program to find the sum of the array
elements using array as function argument.
10. Write a program in C to find whether the given string is palindrome or not without using
inbuilt functions.
Sample Input: madam Expected Output: It is a palindrome.
Sample Input: hello madam Expected Output: It is not a palindrome.
11. Differentiate Call by value and Call by reference with separate example programs.
12. What is a pointer variable? Analyze the following code snippet and write the interpretation
of compiler line by line
int main()
{ int a=12;
int *p;
p=&a;
printf(“a= %d \t a=%u \t *p=%d”, a, &a,*p);
return 0; }
Assume the address of a and p is 4000 and 2000 respectively.
13. What is a structure? Explain the syntax of structure declaration and various ways of initializing
structures with example.
14. Write a program having structure employee with members Employeename, Employee
number, Designation, Department, BasicSalary, DA, HRA, PF and totalsalary. Prompt the
user to enter employee details for n employees and calculate totalsalary as
TotalSalary=BasicSalary+DA+HRA+PF
Finally print the Salary slip for an employee based on the given employee number
15. Write a program to maintain a record of student details using an array of structures with the
fields (rollno, name, mark1, mark2, mark3, mark4, mark5).Assume appropriate data type for
each field. Print the result as Pass or Fail along with name and rollno. If all subject marks are
above 50, result is Pass.