-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
78 lines (63 loc) · 3.8 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Problem Description_1:
Find out the smallest Sum from a Array:
Write a C program to find the sum of contiguous sub array within an array which has the smallest
sum. Also print where in the array the smallest sum occurred.
For example, given the array [4, -1, 2, -3, 1, -2, 7, -5, 4], the contiguous sub-array [1, -3, -2] has the
smallest sum of -4 and it occurred in [0:6].
To understand contiguous sub array, given the array [1, 2, 3] the contiguous sub arrays are [1], [2],
[3], [1, 2], [2, 3], [1, 2, 3], but [1, 3] is not a contiguous sub array.
Problem Description_2:
Calculate Max Profit from share Market:
Say you have an array for which the i
th element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the
stock), design an algorithm to find the maximum profit.
Problem Description_3:
Matrix:
i. Take an integer number n as input. Then take a n*n matrix as input. Suppose the given matrix is
A.
ii. Write a program to interchange diagonals of the matrix A. After interchanging the diagonals
suppose the new matrix is B.
iii. Then write a program in the same main function to get transpose of the matrix B. Suppose the
transpose matrix is C.
iv. Now do the following operation:
3A + 2B – C
Problem Description:
Playing with String:
Task 1: Signup System
In the StringAssignment.c file there are two global arrays of String namely emailArr and passArr.
Implement the function signupUser() that takes two String as input, one for user email and another for
password. You need to do the following checks:
1. Is the email in valid format?
2. Does the password contain at least 8 characters?
3. Does the password have both uppercase and lowercase letters?
4. Does the password contain digits?
5. Does the password contain any of the special characters ($ # * @)?
If any of the checks returns false, the signup will not be successful. In that case you need to show proper
error message, and return FAIL_VAL. Otherwise, the signup will be successful if all of these checks
return true. In that case show success message, return the array index, and store the user email and the
password into emailArr and passAarr respectively.
N.B. You need to discard duplicate signup.
Task 2: Login System
Implement the function loginUser() that takes two String as input, one for user email and another for
password. It will search for the given user email in emailArr. If the user email exists and the given
password matches with the stored one against that email, then login will be successful and you should
return the array index plus show a success message. Otherwise, login will be unsuccessful and you
should return FAIL_VAL plus show a proper error message.
Task 3:Build Profile
In the StringAssignment.c file there are two more global arrays of String namely nameArr and
addressArr. Implement the function buildUserProfile() that takes four String as input, one for user
email, one for first name, one for last name, and another for the address. You need to do the following
thing:
1. Concatenate first and last name to a single name field, and store it into nameArr at the proper
index.
2. Store the address into addressArr at the proper index.
3. If no user is found against the given email, show error message.
Task 4: Search
1. Implement the function searchByName() that takes one String input for name. You need to show
the email, name, and address of those users found against that name.
2. Implement the function searchByAddress() that takes one String input for address. You need to
show the email, name, and address of those users found against that address.
For both of these searches: the search should be case insensitive and allow substring properties. If search
fails to find the data, show error message.
Assignment designed by Md. Rafi-Ur-Rashid, Lecturer, CSE, UIU.