U24 AI029 Ass 2
U24 AI029 Ass 2
Each
two-dimensional array should be processed as array of pointers to a set of 1-
dimensional integer arrays. Read, access and display the matrix elements using pointers
instead of subscript notation. Use three functions i) To read input matrix ii) To compute
the product and iii) To display the resultant matrix.
CODE:
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Matrix 1:\n");
displayMatrix(matrix1);
printf("Matrix 2:\n");
displayMatrix(matrix2);
printf("Resultant Matrix:\n");
displayMatrix(result);
return 0;
}
OUTPUT:
Q2) Write a C program to hold two integer pointers as structure members. Allocate space
for the structure and its data members during runtime. Get one array as input. In the
second array copy the elements of the first array and replace the odd positioned
elements by the product of its adjacent elements. Access the array elements and
structures using pointers instead of subscript notation.
First Array (Input)
123456
Second Array (Output)
1 3 3 15 5 5
CODE:
#include <stdio.h>
#include <stdlib.h>
int main() {
int n;
return 0;
}
OUTPUT:
Q3) Create a Structure called BankMgmt with AccNumber, CustName, AvlBalance,
AccType as members. Implement a Bank management Application as menu driven
program for the above said Structure scenario.
Menu Option:
1. Withdrawal 2. Deposit 3. Display Balance 4. Exit
If option
1 is chosen- Amount can be withdrawn from the account (Withdrawn amount
should be given as input). For withdrawal the condition is- the AvlBalance must be
greater than withdrawn amount).
2 is chosen- Amount can be deposited to the account (the deposited amount
should be given as input). The deposited amount should be reflected in AvlBalance of
the account.
3 is chosen- Current available balance (AvlBalance) of the AccNumber should
be Displayed with other details
Sample Input:
SB 100155 VenkatKrishna 4500.00 Saving
CODE:
#include <stdio.h>
int main() {
BankMgmt account;
printf("Enter account number: ");
scanf("%s", account.AccNumber);
printf("Enter customer name: ");
scanf(" %[^\n]s", account.CustName);
printf("Enter available balance: ");
scanf("%f", &account.AvlBalance);
printf("Enter account type: ");
scanf("%s", account.AccType);
int choice;
do {
printf("\nBank Management Application\n");
printf("1. Withdrawal\n");
printf("2. Deposit\n");
printf("3. Display Balance\n");
printf("4. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
withdraw(&account);
break;
case 2:
deposit(&account);
break;
case 3:
displayDetails(account);
break;
case 4:
printf("Exiting the application.\n");
break;
default:
printf("Invalid choice. Please try again.\n");
}
} while (choice != 4);
return 0;
}
OUTPUT: