

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
C LANGUAGE AND UNIX PROGRAMMING FOR FIRST YEAR UNDERGRADUATES
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


hi hello how are you hello hi hi
No. of occurrences of hi is 2 output string is: hello how are you hello
Second Semester 2019-20 CS F111 Computer Programming
LABORATORY SESSION 10
(Pointers, Pointers to arrays, Multidimensional arrays and Strings)
input.txt
[Note: There are a suite of useful library functions like tolower() and toupper() available in the ctype library. Get to know them by typing man isalpha at the shell prompt. You should be familiar with the first 13 functions – starting from isalnum() and ending with isblank(), whose descriptions are also provided in the manual page, so you can use them in your programs when needed.]
a
b. #include<stdio.h> void function(char**); int main() { char *arr[] = { "ant", "bat", "cat", "dog", "egg", "fly" }; function(arr); return 0; }
void function(char **ptr) { char *ptr1; ptr1 = (ptr += sizeof(int))[-2]; printf("%s\n", ptr1); }
#include<stdio.h> int main() { printf("%d", sizeof(void *)); return 0; }
LABORATORY SESSION 10 (Practice Problems)
(Pointers, Pointers to arrays, Multidimensional arrays and Strings)
a. Read and store the transaction details of one given day for all the branches in a 2D array. First, the program should read values for m and n , and then read and store the transaction values in an m x n array.
b. Find and print out the maximum value of amount withdrawn on that particular day (across all branches). Write a function (whose prototype is given below) that accomplishes this: (COLS and ROWS are preprocessor declared constants). int findMaxWithdrawal(int data[][COLS], int m, int n);
c. Print the branch number (same as row number) of the branch that recorded the maximum total amount in deposits from the data. Write and use the following function to achieve this task: int computeMaxDeposit(int row[], int n, int *max); While this function returns back the branch number to the calling function, it also stores the maximum value of the deposits using a pointer) [Hint: This function should be repeatedly called to find out the maximum total deposits of a given row (which it takes as the first argument.)]
d. Print the branch number of the branch that had recorded maximum transaction value. int computeMaxTransac(int row[], int size); [Hint: Use the abs() function whose prototype is stored in the <stdlib.h> library, or implement the equivalent functionality yourself.]
Few sample I/P and O/P instance is given below:
S1 = Programming S2 = Computer S3 = Computer Programming
S1 = Computer S2 = Conputer S3 = Computer
S1 = Computer S2 = Program S3 = Computer Program
Note: To achieve the task, you are not allowed to any string processing functions.