Tuesday, January 24, 2023

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 8.Print twin prime numbers within a range.

PROGRAM:

echo "enter a range:"
read a
read b
n=$a
while [ $n -le $b ]
do
    c=0
    d=1
    while [ $d -le $n ]
    do
        if [ `expr $n \% $d` -eq 0 ]
        then
            c=`expr $c + 1`
        fi
        d=`expr $d + 1`
    done

    if [ $c -eq 2 ]
    then
        f=$n
        e=`expr $n + 2`
        m=$e
        c=0
        d=1
        while [ $d -le $m ]
        do
            if [ `expr $m \% $d` -eq 0 ]
            then
                c=`expr $c + 1`
            fi
            d=`expr $d + 1`
        done
        if [ $c -eq 2 ]
        then
            echo "twin prime pair=$f,$e"
        fi
       
    fi
n=`expr $n + 1`
done

OUTPUT:

enter a range:
2
10
twin prime pair=3,5
twin prime pair=5,7
[bgc@localhost ~]$ sh 9.sh
enter a range:
3
100
twin prime pair=3,5
twin prime pair=5,7
twin prime pair=11,13
twin prime pair=17,19
twin prime pair=29,31
twin prime pair=41,43
twin prime pair=59,61
twin prime pair=71,73
[bgc@localhost ~]$

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 7. Prime number checking.

PROGRAM:

echo "enter a number:"
read n

    c=0
    d=1
    while [ $d -le $n ]
    do
        if [ `expr $n \% $d` -eq 0 ]
        then
            c=`expr $c + 1`
        fi
        d=`expr $d + 1`
    done

if [ $c -eq 2 ]
then
    echo "prime number"
else
    echo "not a prime number"   
fi


OUTPUT:

[bgc@localhost ~]$ sh 8.sh
enter a number:
2
prime number
[bgc@localhost ~]$ sh 8.sh
enter a number:
1
not a prime number
[bgc@localhost ~]$ sh 8.sh
enter a number:
0
not a prime number
[bgc@localhost ~]$ sh 8.sh
enter a number:
5
prime number
[bgc@localhost ~]$ sh 8.sh
enter a number:
4
not a prime number
[bgc@localhost ~]$

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 6. Print fibonacci series.

PROGRAM:

echo "enter number of elements of the fibonacci series:"
read n
a=0
b=1
if [ $n -eq 0 ]
then
    echo "no elemnts"
else
    if [ $n -eq 1 ]
    then
        echo 0
    else
        echo 0
        echo 1
        c=2
        while [ $c -ne $n ]
        do
            d=`expr $a + $b`
            echo $d   
            a=$b
            b=$d
            c=`expr $c + 1`
        done
    fi
fi

OUTPUT:

[bgc@localhost ~]$ sh 7.sh
enter number of elements of the fibonacci series:
6
0
1
1
2
3
5
[bgc@localhost ~]$

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 5. Find out the factorial of a number.

PROGRAM:

echo "Enter the number:"
read n
fact=1
if [ $n -eq 0 ]
then
    echo "fact = "1
else
   
        for i in `seq 1 $n`
        do
            fact=`expr $fact \* $i`
        done
        echo "fact = $fact"

fi

OUTPUT:

[bgc@localhost ~]$ sh 6.sh
Enter the number:
3
fact = 6
[bgc@localhost ~]$ sh 6.sh
Enter the number:
2
fact = 2
[bgc@localhost ~]$ sh 6.sh
Enter the number:
0
fact = 1
[bgc@localhost ~]$

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 4.Check a number whether it is odd positive,odd negative,even positive,even negative.

PROGRAM:

echo "enter a number:"
read n
if [ $n -ge 0 ]
then
    if [ `expr $n % 2` -eq 0 ]
    then
        echo "$n is a even positive number"
    else
        echo "$n is a odd positive number"
    fi
else
    if [ `expr $n % 2` -eq 0 ]
    then
        echo "$n is a even negative number"
    else
        echo "$n is a odd negative number"
    fi
fi


OUTPUT:


[bgc@localhost ~]$ sh 5.sh
enter a number:
3
3 is a odd positive number
[bgc@localhost ~]$ sh 5.sh
enter a number:
0
0 is a even positive number
[bgc@localhost ~]$ -9
bash: -9: command not found...
[bgc@localhost ~]$ sh 5.sh
enter a number:
-9
-9 is a odd negative number
[bgc@localhost ~]$ sh 5.sh
enter a number:
-10
-10 is a even negative number
[bgc@localhost ~]$

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 3. Leap year checking.

PROGRAM:

echo "enter the year:"
read n
if [ `expr $n % 4` -eq 0 ]
then
    if [ `expr $n % 100` -eq 0 ]
    then
        if [ `expr $n % 400` -eq 0 ]
        then
            echo "$n is a leapyear"   #2000
        else
            echo "$n is not a leapyear"  #1900
        fi
    else
        echo "$n is a leapyear"  #1996
    fi
else
    echo "$n is not a leapyear"  #1997
fi

OUTPUT:

[bgc@localhost ~]$ sh pc2.sh
enter the year:
1996
1996 is a leapyear
[bgc@localhost ~]$ sh pc2.sh
enter the year:
2000
2000 is a leapyear
[bgc@localhost ~]$ sh pc2.sh
enter the year:
1997
1997 is not a leapyear
[bgc@localhost ~]$ sh pc2.sh
enter the year:
1900
1900 is not a leapyear
[bgc@localhost ~]$

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 2. Use of for loop.

PROGRAM:

echo "Enter number of elements:"
read n
for i in `seq 1 $n`
do
    echo $i
done

OUTPUT:

[bgc@localhost ~]$ sh pc.sh
Enter number of elements:
3
1
2
3
[bgc@localhost ~]$ 

Unix Shell Programming Example for B.Sc, B.Tech, BCA, MCA

 1. Use of while loop.

PROGRAM:

echo "enter no. of elements:"
read n
a=0
while [ $a -ne $n ]
do
    echo $a
    ((a++))
done

OUTPUT:

[bgc@localhost ~]$ sh pc1.sh
enter no. of elements:
3
0
1
2
[bgc@localhost ~]$

Tuesday, October 18, 2022

Cloud computing QUESTION SET 1

 

1. Defining Cloud Computing.

2. Cloud Computing Is a Service.

3. 5-4-3 Principles of Cloud computing.

4. Give a brief note on the merits and demerits of cloud computing.

5. Cloud Architecture.

6. What is public cloud access networking?

7. Compare and contrast public and private clouds.

8. What is SLA? Are SLAs different for each type of cloud deployment?

9.  What are the characteristics of hybrid cloud?

10. What are the advantages of using the community cloud?

11. Define Infrastructure as a Service (IaaS).

12. Define Platform as a Service (PaaS).

13. Define Software as a Service (SaaS).

14. Write short notes on end user and service provider responsibilities of cloud service models with a suitable diagram.

15. Explain in detail about the overview of IaaS, PaaS, and SaaS with suitable diagrams.

16. Write short notes on pros and cons of IaaS, PaaS, and SaaS.

Tuesday, June 7, 2022

BIG DATA sample question

 What is Big Data? Advantages and disadvantages of Hadoop

How is HADOOP related to Big Data? 

Describe the main features of a big data in detail.

Hadoop – Architecture

Explain any one of the Hadoop components.

What is the difference between Hadoop and Traditional RDBMS?

What is NoSQL? 

Explain four types of NoSQL in brief.

SQL vs NoSQL