0% found this document useful (0 votes)
19 views3 pages

Programming Fundamentals Assignment 3 Instructions:: Encrypt

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Programming Fundamentals Assignment 3 Instructions:: Encrypt

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Fundamentals Assignment 3

Instructions:
 Assignment must be submitted handwritten.
 Assignment must have a cover page including students registration number, name,
discipline (BSSE, BSAI, BSCS) and section
 Copied assignment will be marked 0
 Assignment must be submitted in second lecture of week 16
 After dead line assignment will not be accepted
 You are also required to submit solution file of your assignment in lab.

Note: All the question carry 20 marks.


Question 1:
Data security now a days is very important. To make data secure, data is encrypted, for data
encryption you are supposed to make a function name encrypt that receives char type array as
argument. This function encrypts data of array in such a way that it first reverses the data of array,
after reversing array it replace every char with its next char and replaces spaces with @. Write
definition of encrypt function only.
Array before passing to function

I C C C U P E N G \0

Array after passing to function:


Step1 reverse the array:

G N E P U C C C I \0
Step2 Replacing a char:

H O F @ Q V D @ D D J \0

Question 2:
Make a structure name NIC having data member’s cardnumber (char array of size 15), name
(char array of size 20), address (char array of size 100), month (int), day (int) and year (int).
Declare user defined size array of NIC. Take input in array and validate following. Data of name
should contains only alphabets (pass name to function validname as argument that returns true if
name is valid and false if name is invalid), value of month should be between 1-12 (including 1
and 12), value of day must be between 1-31 (including 1 and 31), value of year must be positive
integer and data of cardnumber must follow one of two formats.
1. 12345-1234567-8 Length must be 15, first 5 character should be digit followed by
–, next 7 character must be digit followed by a – and last character must be digit.
2. 1234512345678 Length must be 13 and all characters must be digit.
Pass cardnumber to a function validcardnumber that returns true if cardnumber follows one
above format and returns false if it’s not according to above format.
Question 3:
Data travels over a network in the form of packets and packets are composed of bytes. Assuming
that size of each packet is 8 bytes. For example, if data has 3 packets and starting byte number of
packet 1 is 800 than packet 2 will have starting byte number 808 and packet 3 will have starting
byte number 816. All the packet numbers have difference of 8, since each packet is 8 bytes.
Write C++ functions to handle the following scenario. You are supposed to input number of
packets data is divided into (i.e. number packets data has). Declare an array for storing starting
byte number of each packet. Input in array the starting byte numbers of each packet in data. After
input display one of the following messages.
 No packet is loss.
 All received but are not in order.
 Data corrupted.
For example:
If data is divided into 4 packets.
No packet is loss All received but are not Data corrupted.
in order.

812 820 828 836 820 812 828 836 812 824 836 828
By looking at above data we can By looking at above data As each packet consist of 8
say all the packets for data is in we can say all packets are byte, there must be difference
order and no packet is loss. As each received but the packet of 8 in packet number we can
cell has the value that has number 812 and 820 are see difference between 812
difference of 8 with other cell and not in order. and 824 is of 12 it means data
are in order is corrupted.

Note: User can enter any number for packets data is divided into, and any data in array.
Assuming that minimum value is for the starting packet number.
Question 4:
Write a program that finds the smallest and largest substring in a given char array. For example, if
array contains following value = 'My Village is a beautiful place', your program should print "a"
and “beautiful”. Size of array should be entered from user.
Question 5:
Date Printer Write a program that reads a char array from the user containing a date in the form
mm/dd/yyyy. It should print the date in the form March 12, 2014.
For example
Enter Date 5/14/2019
May 14, 2019
Validation Required: Month should be less than 13, day should be less than 31

Question 6: Declare a 2 dimension array of having 3 rows and 4 columns. Input in array and
display sum of rows and sum of columns

You might also like