Professional Documents
Culture Documents
INDEX
PAGE
S.NO CONTENTS
NO.
1 VISION/MISION 4
2. PEO 4
3. POS 5
5. COS 6
6. MAPPING OF CO & PO 6
7. SYLLABUS 7
8. BOOKS 8
9. INSTRUCTIONAL METHODS 8
Exp:- 1 EXPERIMENT-1 :Use of Basic Unix Shell Commands: ls, mkdir, rmdir, cd, 16
cat, banner, touch, file, wc, sort, cut, grep, dd, dfspace, du, ulimit.
Exp:- 2 EXPERIMENT-2 : Commands related to inode, I/O redirection and piping, 24
process control commands, mails.
Exp:-3 EXPERIMENT-3 : Shell Programming: Shell script exercises based on 28
following
3.1 Greatest among three numbers
3.2 To find a year is leap year or not
3.3 To input angles of triangle and finds out whether it is valid
triangle or not
3.4 To check whether a character is alphabet, digit or special
[LSP LAB – 4CS4 – 24]Page 2
Jaipur Engineering College and Research Centre, Jaipur
Department of Computer Science & Engineering
character.
3.5 To calculate profit and loss
MISSION:
M1: To impart outcome based education for emerging technologies in the field of computer science
and engineering.
M2: To provide opportunities for interaction between academia and industry.
M3: To provide platform for lifelong learning by accepting the change in technologies
M4: To develop aptitude of fulfilling social responsibilities.
PEO
1. To provide students with the fundamentals of Engineering Sciences with more emphasis in
Computer Science &Engineering by way of analyzing and exploiting engineering challenges.
2. To train students with good scientific and engineering knowledge so as to comprehend, analyze,
design, and create novel products and solutions for the real life problems.
3. To inculcate professional and ethical attitude, effective communication skills, teamwork skills,
multidisciplinary approach, entrepreneurial thinking and an ability to relate engineering issues
with social issues.
4. To provide students with an academic environment aware of excellence, leadership, written
ethical codes and guidelines, and the self motivated life-long learning needed for a successful
professional career.
5. To prepare students to excel in Industry and Higher education by Educating Students along with
High moral values and Knowledge
PROGRAM OUTCOMES
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and Computer Science & Engineering specialization to the solution of
complex Computer Science & Engineering problems.
2. Problem analysis: Identify, formulate, research literature, and analyze complex computer
Science & Engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex Computer Science&
Engineering problems and design system components or processes that meet the specified
needs with appropriate consideration for the public health and safety, and the cultural,
societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of Computer Science & Engineering experiments, analysis and
interpretation of data, and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
Computer Science& Engineering and IT tools including prediction and modeling to complex
computer science engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant
to the professional Computer Science & Engineering practice.
7. Environment and sustainability: Understand the impact of the professional Computer
Science & Engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the Computer Science & Engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings in Computer Science & Engineering.
10. Communication: Communicate effectively on complex Computer Science & Engineering
activities with the engineering community and with society at large, such as, being able to
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
Computer Science & Engineering and management principles and apply these to one’s own
work, as a member and leader in a team, to manage projects and in multidisciplinary
environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of Computer Science&
Engineering change.
OBJECTIVES
1 2 3 4 5 6 7 8 9 10 11 12
I 3 1 3
II 2 3 2 3 3 1 3
III 1 3 2 3 1 2
IV 1 2 3 2 3 2
V 2 2
3- High
2- Medium
1- Low
COURSE OUTCOMES
[LSP LAB – 4CS4 – 24]Page 8
Jaipur Engineering College and Research Centre, Jaipur
Department of Computer Science & Engineering
MAPPING OF CO & PO
I 3 2 2 2 2 1 1 1 1 2 2 3
II 3 3 3 2 2 1 1 1 1 1 2 3
3- High
2- Medium
1-Low
SYLLABUS
Objectives:
At the end of the semester, the students should have clearly understood and implemented the following:
Reference
8. BOOKS:-
● UNIX Shell programming, By Stephen G. Kochan, Patrick H. Wood
● Behrouz A. Forouzan, Richard F. Gilberg, UNIX and Shell Programming, Thomson, 2003.
● Brian W. Kernighan, Rob Pike, The UNIX Programming Environment, PHI, 1996
● K. Srirengan, Understanding UNIX, PHI, 2002
● Sumitabha Das, Your UNIX- The Ultimate Guide, TMGH, 2002
● Sumitabha Das, UNIX Concepts and Applications, Second Edition, TMGH, 2002
INSTRUCTIONAL METHODS:-
● Direct Instructions:
Through Projectors & White Board with Marker
● Interactive Instruction:
Programs
● Indirect Instructions:
Problem solving
LEARNING MATERIALS:-
● Text/Lab Manual
ASSESSMENT OF OUTCOMES:-
INSTRUCTIONS OF LAB
DO’s
[LSP LAB – 4CS4 – 24]Page 11
Jaipur Engineering College and Research Centre, Jaipur
Department of Computer Science & Engineering
DON’TS
1. No one is allowed to bring storage devices like Pan Drive /Floppy etc. in the lab.
2. Don’t mishandle the system.
3. Don’t leave the system on standing for long
4. Don’t bring any external material in the lab.
5. Don’t make noise in the lab.
6. Don’t bring the mobile in the lab. If extremely necessary then keep ringers off.
7. Don’t enter in the lab without permission of lab Incharge.
8. Don’t litter in the lab.
9. Don’t delete or make any modification in system files.
10. Don’t carry any lab equipments outside the lab.
We need your full support and cooperation for smooth functioning of the lab.
● All the students are supposed to prepare the theory regarding the next program.
● Students are supposed to bring the practical file and the lab copy.
● Previous programs should be written in the practical file.
● Any student not following these instructions will be denied entry in the lab.
EXPERIMENT NO.- 1
Use of Basic Unix Shell Commands: ls, mkdir, rmdir, cd, cat, banner, touch, file, wc, sort, cut,
grep, dd, dfspace, du, ulimit.
ls command
The ls command lists all files in the directory that match the name. If name is left blank, it will list all of
the files in the directory.
The syntax for the ls command is:
ls [options] [names]
Options:
pwd command.
pwd command will print your home directory on screen, pwd means present working directory.
/u0/ssb/sandeep
is output for the command when I use pwd in /u0/ssb/sandeep directory.
grepcommand
The grep command allows you to search one file or multiple files for lines that contain a pattern. Exit
status is 0 if matches were found, 1 if no matches were found, and 2 if errors occurred.
The syntax for the grep command is:
grep [options] pattern [files]
Options:
-b Display the block number at the beginning of each line.
-c Display the number of matched lines.
-h Display the matched lines, but do not display the filenames.
-i Ignore case sensitivity.
-l Display the filenames, but do not display the matched lines.
-n Display the matched lines and their line numbers.
-s Silent mode.
-v Display all lines that do NOT match.
-
Match whole word.
w
dd command
Copy a file, converting and formatting according to the options.
Syntax
dd [OPERAND]...
dd OPTION
Options :
bs=BYTES force ibs=BYTES and obs=BYTES
mkdir command.
#mkdir sandeep will create new directory, i.e. here sandeep directory is created.
#cd command.
cd sandeep will change directory from current directory to sandeep directory. Use pwd to check your
current directory and ls to see if sandeep directory is there or not. You can then use cd sandeep to
change the directory to this new directory.
#rmdir command.
Options:
#cat command
Reading Files
#cat file1
Concatenation
For example, the following command will concatenate copies of the contents of the three files file1, file2
and file3:
#cat file1 file2 file3
This output could just as easily be redirected using the output redirection operator to another file, such as
file4, using the following:
#cat file1 file2 file3 > file4
File Creation
#cat > file1
If a file named file1 already exists, it will be overwritten (i.e., all of its contents will be erased) by the
new, empty file with the same name. Thus the cautious user might prefer to instead use the append
operator (represented by two successive rightward pointing angular brackets) in order to prevent
unintended erasure. That is,
#cat >> file1
That is, if an attempt is made to create a file by using cat and the append operator, and the new file
has the same name as an existing file, the existing file is, in fact, preserved rather than overwritten,
and any new text is added to the end of the existing file.
Typing the following and then pressing ENTER creates a new file named file2 that contains copy of
the contents of file1:
#cat file1 > file2
For example, to create a new file file6 that consists of text typed in from the keyboard followed by
the contents of file5, first enter the following:
#cat - file5 > file6
Or to create a new file file8 that consists of the contents of file7 followed by text typed in from the
keyboard, first enter the following:
# cat file7 -> file8
#Banner command.
banner prints characters in a sort of ascii art poster, for example to print wait in big letters. I will type
banner wait at unix command line or in my script. This is how it will look.
# # ## # #####
# # # # # #
# # # # # #
# ## # ###### # #
## ## # # # #
# # # # # #
# touch command
#touch file1
#wc command
wc command counts the characters, words or lines in a file depending upon the option.
Options
#du command.
● "du" stands for disk usage. This command is used to show the amount of disk space consumed
by one or more directories
● Syntax:
● du [-a] [-k] [-s] [-d] [-L] [-o] [-r] [-x] directories
-k Write the files sizes in units of 1024 bytes, rather than the default 512-byte units.
-s Instead of the default output, report only the total sum for each of the specified files.
-d Do not cross filesystem boundaries. For example, du -d / reports usage only on the
root partition.
-L Process symbolic links by using the file or directory which the symbolic link
references, rather than the link itself.
-o Do not add child directories' usage to a parent's total. Without this option, the usage
listed for a particular directory is the space taken by the files in that directory, as well
as the files in all directories beneath it. This option does nothing if -s is used.
-r Generate messages about directories that cannot be read, files that cannot be opened,
and so forth, rather than being silent (the default).
-x When evaluating file sizes, evaluate only those files that have the same device as the
file specified by the file operand.
#who command
Options:
#dfspace Command:
● The dfspace command formats the output for the df command to make it easier to read.
● sort command:
● Sorts the lines in a text file.
● Syntax:
● sort [options]... [file]
-f Ignores caps
-M Treats the first three letters in the line as a month (such as may.)
-T Use DIR for temporaries, not $TMPDIR or /tmp; multiple options specify
multiple directories
-u If line is duplicated only display once
EXPERIMENT NO.-2
Commands related to inode, I/O redirection and piping, process control commands, mails.
Inode:-
Inodes in Unix are data structures which contain all the properties of a file, metadata. The properties
of the file include file size, file owner, the group to which the file belongs to, file access rights, hard
link count, the location where the file contents are present and time stamps(last modified time, last
accessed time, last changed time). In other words, the inode data structure contains all the
information of the file except the file name and its contents.
$ ls –i
1448240 a 1441807 Desktop 1447344 mydata 1441813 Pictures 1442737 testfile 1448145
worm 1448240 a1 1441811 Documents 1442707 my_ls 1442445 practice 1442739 test.py
1447139 alpha 1441808 Downloads 1447278 my_ls_alpha.c 1441810 Public 1447099
1447478 article_function_pointer.txt 1575132 google 1447274 my_ls.c 1441809 Templates
1442390 chmodOctal.txt 1441812 Music 1442363 output.log 1448800 testdisk.log 1575133
vlc
See that the Inode number for ‘a’ and ‘a1’ are same as we created ‘a1’ as hard link.
ii) Df -i Command
df -i command displays the inode information of the file system.
$ df –i
Standard Output
Most command line programs that display their results do so by sending their results to a facility
called standard output. By default, standard output directs its contents to the display. To redirect
standard output to a file, the ">" character is used like this:
In this example, the ls command is executed and the results are written in a file named file_list.txt.
Since the output of ls was redirected to the file, no results appear on the display.
Each time the command above is repeated, file_list.txt is overwritten (from the beginning) with the
output of the command ls. If you want the new results to be appended to the file instead, use ">>"
like this:
When the results are appended, the new results are added to the end of the file, thus making the file
longer each time the command is repeated. If the file does not exist when you attempt to append the
redirected output, the file will be created.
Standard Input
Many commands can accept input from a facility called standard input. By default, standard input
gets its contents from the keyboard, but like standard output, it can be redirected. To redirect
standard input from a file instead of the keyboard, the "<" character is used like this:
In the above example we used the sort command to process the contents of file_list.txt. The results
are output on the display since the standard output is not redirected in this example. We could
redirect standard output to another file like this:
As you can see, a command can have both its input and output redirected. Be aware that the order of
the redirection does not matter. The only requirement is that the redirection operators (the "<" and
">") must appear after the other options and arguments in the command.
Pipes
The most useful and powerful thing you can do with I/O redirection is to connect multiple
commands together with what are called pipes. With pipes, the standard output of one command is
fed into the standard input of another.
In this example, the output of the ls command is fed into less. By using this "| less" trick, you can
make any command have scrolling output. I use this technique all the time.
By connecting commands together, you can acomplish amazing feats. Here are some examples you'll
want to try:
Here "PID" is refer to the process ID, that you can get from command "ps -aux"
fg PID
Bring a background or stopped process to the foreground.
bg PID
Send the process to the background. Opposite to fg. The same can be accomplished with z. If you
have stopped jobs, you have to type exit twice in row to log out.
any_command&
Run any command in the background (the symbol "&" means "run the proceeding command in the
background").
batch any_command
Run any command (usually one that is going to take more time) when the system load is low. I can
logout, and the process will keep running.
at 17:00
Execute a command at a specified time. You will be prompted for the command(s) to run, until you
press d.
kill PID
Force a process shutdown. First determine the PID of the process to kill using ps.
killall program_name
Kill program(s) by name.
kill -9 11
EXPERIMENT NO. - 3
Shell Programming: Shell script based on control structure- If-then-fi, if-then else-if,
nested if-else, to find:
(A) Greatest among three numbers.
(B) To find a year is leap year or not.
(C) To calculate profit or loss.
(D) To input angles of triangle and finds out whether it is valid triangle or not
(E) To check whether a character is alphabet, digit or special character.
#!/bin/bash
echo "enter first number"
read first
echo "enter second number"
read sec
echo "enter third number"
read third
if [ $first -gt $sec ] ; then
if [ $first -gt $third ] ; then
echo -e " $first is greatest number "
else
78 is greatest number
:-$
2006
2000
:-$
clear
Output-
:-$ geditpl1.sh
:-$ bashpl1.sh
:-$
(D) To input angles of triangle and finds out whether it is valid triangle or not
bool is Valid Triangle (int a, int b, int c)
{
int longestSide = a;
if (b > longestSide )
longestSide = b;
if(c > longestSide )
longestSide = c;
return (longestSide < a + b + c - longestSide);
}
Output-
:-$ gedit tri.c
:-$ gcc -o tri tri.c
:-$ ./tri
Enter three angles of triangle:
30
60
90
Triangle is valid.
:-$
EXPERIMENT NO. - 4
(A) Write a shell script to print all even and odd number from 1 to10.
(B) Write a shell script to print table of a given number
(C) Write a shell script to calculate factorial of a given number.
(D) Write a shell script to print sum of all even numbers from 1 to 10.
(E) Write a shell script t print sum of digits of any number.
( A) Write a shell script to print all even and odd number from 1 to 10. Code-
Output-
4 x 7 =28
4 x 8 =32
4 x 9 =36
4 x 10 = 40
:-$
Output-
:-$ gedit fact.sh
:-$ bash fact.sh enter a number The factorial of 5 is 120
:-$
(D) Write a shell script to print sum of all even numbers from 1 to 10.
read n
# store single digit
sd=0
# store number of digit
sum=0
# use while loop to caclulate the sum of all digits
while [ $n -gt 0 ]
do
sd=$(( $n % 10 )) # get Remainder
n=$(( $n / 10 )) # get next digit
sum=$(( $sum + $sd )) # calculate sum of digit
done
echo "Sum of all digit is $sum"
Output-
:-$ gedit digit.sh
enter the
number
23456
the sum of 23456 is 20
:-$
EXPERIMENT NO. - 5
(A) Write a shell script to make a basic calculator which performs addition,
subtraction, multiplication, division.
(B) Write a shell script to print sum of all even numbers from 1 to10.
(A) Write a shell script to make a basic calculator which performs addition, subtraction,
multiplication, division.
Output-
Enter operator(+, -, /, *):+
Enter number1:100
Enter number2:50
100 + 50 = 150
Enter operator (+, -, /, *):*
Enter number1:90
Enter number2:5
90 * 5 = 450
Output:
$sh a.sh
Enter a number: 4
Wednesday
month="$1"
if [ -z "$month" ] || [ ${#month} != 6 ]; then
echo must specify yyyymm, e.g. $(date +%Y%m)
exit 2
fi
year=${month:0:4}
month=${month:4:2}
echo $((
(
EXPERIMENT NO. - 6
Output-
:-$ gedit armstrong.sh
#!/bin/bash
# Shell script to find whether an input number is palindrome or
not #
echo -n "Enter number :"
read n
# store single digit
sd=0
# store number in reverse order
rev=""
# store original
number on=$n
while [ $n -gt 0 ]
do
sd=$(( $n % 10 ))
# get Remainder n=$(( $n / 10 ))
# get next digit
Output-
:-$ gedit pal11.sh
:-$ bash pal11.sh
Enter number : 123
Number is NOT palindrome
:-$ bash pal11.sh
Enter number : 121
Number is
palindrome
:-$
# Fibonacci Series
a=0
# Second Number of the
# Fibonacci Series
b=1
echo "The Fibonacci series is : "
for (( i=0; i<N; i++ ))
do
echo -n "$a "
fn=$((a + b))
a=$b
b=$fn
done
# End of for loop
Output:
0 1 1 2 3 5 8 13 21 34 55
:-$
i=2
f=0
while [ $i -le `expr $num / 2` ]
do
if [ `expr $num % $i` -eq 0 ]
then
f=1
fi
i=`expr $i + 1`
done
if [ $f -eq 1 ]
then
echo "The number is composite"
else
echo "The number is Prime"
fi
Output-
:-$ gedit prime.sh
:-$ bash prime.sh
enter number
7
it is prime
:-$ bash prime.sh
enter number
4
it is not prime
:-$
(E) Write a shell script to convert binary to decimal and decimal to binary.
done
echo "Equivalent Binary no:" $final ;;
2) echo "Enter any Binary no;"
read bino
len=${#bino}
i=1
pow=$((len - 1 ))
while [ $i -le $len ]
do
n=`echo $bino | awk '{ printf substr( $0,'$i',1 )}' `
j=1
p=1
while [ $j -le $pow ]
do
p=$(( p * 2 ))
j=$(( j + 1 ))
done
dec=$(( n * p ))
findec=$(( findec + dec ))
pow=$((pow - 1 ))
i=$(( i + 1 ))
done
echo "Equivalent Decimal no:"$findec ;;
3) echo "Enter correctly:" ;;
esac
Output-
Conversion of decimal to Binary and Binary to Decimal
1. Convert Decimal toBinary
EXPERIMENT NO. - 7
Write a shell script to print different shapes- Diamond, triangle, square, rectangle, hollow square etc.
Rectangle-
Code-
/**
return 0;
}
Output-
:-$ ./rectangle
**********
**********
**********
**********
**********
:-$
Diamond-
Code-
/**
int i, j, rows;
int stars, spaces;
printf("Enter rows to print : ");
scanf("%d", &rows);
stars = 1;
spaces = rows - 1;
/* Iterate through rows */
for(i=1; i<rows*2; i++)
{
/* Print spaces */
for(j=1; j<=spaces; j++)
printf("");
/* Print stars */
for(j=1; j<stars*2; j+
+) printf("*");
/* Move to next line */
printf("\n");
if(i<rows)
{
spaces--;
stars++;
}
else
{
spaces++;
stars--;
}
}
return 0;
}
Output-
:-$ ./diamond
***
*****
*******
*********
*******
*****
***
*
:-$
Triangle-
Code-
/*
Output-
:-$ ./triangle
Enter value of n: 5
**
***
****
*****
:-$
Square-
Code-
/**
#include
<stdio.h>intmain()
{
int i, j,N;
/* Input number of rows from user */
printf("Enter number of rows: ");
scanf("%d", &N);
/* Iterate through N rows */
for(i=1; i<=N;i++)
{
/* Iterate over columns*/
for(j=1; j<=N;j++)
{
/* Print star for each column */
printf("*");
}
/* Move to the next line/row */
printf("\n");
}
return 0;
}
Output-
:-$ ./sqr
*****
*****
*****
*****
*****
:-$
Hollow Square
Code-
/**
}
/* Move to the next line/row */
printf("\n");
}
return 0;
}
Output-
or directory
:-$ ./hsqr
*****
* *
* *
* *
*****
EXPERIMENT NO. - 8
#include <stdio.h>
void main()
{
int arr[10];
int i;
printf("\n\nRead and Print elements of an array:\n");
printf("-----------------------------------------\n");
printf("Input 10 elements in the array :\n");
for(i=0; i<10; i++)
{
printf("element - %d : ",i);
scanf("%d", &arr[i]);
}
printf("\nElements in array are: ");
for(i=0; i<10; i++)
{
Output-
:-$ ./arr1
element - 0 :9
element - 1 :4
element - 2 :6
element - 3 :3
element - 4 :4
element - 5 :56
element - 6 :23
element - 7 :65
element - 8 :78
element - 9 :90
:-$
#include <stdio.h>
void main()
{
int a[100];
int i, n, sum=0;
printf("\n\nFind sum of all elements of array:\n");
printf("--------------------------------------\n");
printf("Input the number of elements to be stored in the array :");
scanf("%d",&n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)
{
printf("element - %d : ",i);
scanf("%d",&a[i]);
}
for(i=0; i<n; i++)
{
sum += a[i];
}
printf("Sum of all elements stored in the array is : %d\n\n", sum);
}
Output-
[LSP LAB – 4CS4 – 24]Page 55
Jaipur Engineering College and Research Centre, Jaipur
Department of Computer Science & Engineering
:-$ ./sum1
element - 0 :6
element - 1 :5
element - 2 :8
element - 3 :3
:-$
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
}
}
/* Utility that prints out an array on a line */
void printArray(int arr[], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("\n");
}
/* Driver function to test above functions */
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6};
printArray(arr, 6);
rvereseArray(arr, 0, 5);
printf("Reversed array is \n");
printArray(arr, 6);
return 0;
}
Output-
:-$ ./reverse1
45
87
32
09
Array in reverseorder:9 32 87 45 70
scanf("%d",&Search);
Flag = 0;
for(i = 0; i < Size; i++)
{
if(arr[i] == Search)
{
Flag = 1;
break;
}
}
if(Flag == 1)
{
printf("\n We found the Search Element %d at Position %d ", Search, i + 1);
}
else
{
printf("\n Sorry!! We haven't found the the Search Element %d ", Search);
}
return 0;
}
Output-
:-$ gedit search.c
:-$ gcc -o search search.c
:-$ ./search
Enter number of elements in array
5
[LSP LAB – 4CS4 – 24]Page 59
Jaipur Engineering College and Research Centre, Jaipur
Department of Computer Science & Engineering
Enter 5 integer(s)
4
6
8
2
4
Enter a number to search
6
6 is present at location 2.
(E) Write a C program to sort array elements in ascending or descending order.
1. #include <stdio.h>
2. #define MAXSIZE 10
3. void main()
4. {
int array[MAXSIZE];
int i, j, num, temp;
printf("Enter the value of num \n");
scanf("%d", &num);
printf("Enter the elements one by one \n");
for (i = 0; i < num; i++)
{
scanf("%d", &array[i]);
}
printf("Input array is \n");
for (i = 0; i < num; i++)
{
printf("%d\n", array[i]);
}
/* Bubble sorting begins */
for (i = 0; i < num; i++)
{
for (j = 0; j < (num - i - 1); j++)
{
if (array[j] > array[j + 1])
{
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
printf("Sorted array is...\n");
for (i = 0; i < num; i++)
{
printf("%d\n", array[i]);
}
}