FOSS-LAB-SET-3
1. There are N switches which are initially OFF. First you turn ON every
switch. Then, you turn off every second switch. On the third round, you
toggle every third switch (turning ON if it’s OFF and turning OFF if it’s
ON).
For the ith round, you toggle every ith switch.
For the Nth round, you only toggle the last switch.
Write a shell script to find the no. of switches that are ON after N rounds.
Input Format : N
Where N - Number of Switches
Sample
Input : 6
Output : 2
Explanation
The first and fourth bulbs remain ON.
Initially OFF OFF OFF OFF OFF OFF
After 1st Round ON ON ON ON ON ON
After 2nd Round ON OFF ON OFF ON OFF
After 3rd Round ON OFF OFF OFF ON ON
After 4th Round ON OFF OFF ON ON ON
After 5th Round ON OFF OFF ON OFF ON
After 6th Round ON OFF OFF ON OFF OFF
(This is more of a mathematical question. We suggest you find out
pattern and then solve this one rather than procedurally doing what is exactly
given in the question, You could maybe do this by hand for say N = 10 or
greater).
FOSS-LAB-SET-3
2. Write a bash script to compile all C source files( with .c extension) under a
directory with ’gcc’(scan recursively in subdirectories). Save object files to
a directory named ’bin’ in the same directory as of the source file. Also
name object files with the same name as of the source files.
(Test case Available in Folder ‘2’)
3. Implement a PHP application to print out multiplication table for any
number given as input.
Exam Report should be prepared with following contents.
A proper report is to be submitted after the examination. It should include at
least the following:
1. A title page that includes subject, date, author name, roll no and
University Register Number.
2. Problem statement.
3. Brief explanation of the theory related to your problem.
4. A description of your implementation. Explain in abstract terms (not
program syntax) how it works and why you chose your particular
solution to the problem. Show diagrams if you like.
5. Pointers to readable source files, executable files, and the shell
commands used to compile, start the programs etc.
6. Informative listings of test runs, i.e. at least Three or Four test runs.
7. Listings of well-commented and well-structured programs.