Total Pageviews

Sunday, May 16, 2021

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-7)

1. electromagnetic spectrum.
2. guided medium, un-guided medium.
3. twisted pair- UTP,STP
4. RJ-45
5. 10Base-T, 100 Base-T.
6. Coaxial Cable 
7. BNC connector
8. Fiber optic cable
9. angle of incidence, critical angle.
10. cladding.
11. multimode step-index fiber, multimode graded-index fiber,
12. single mode
13. SC connector, ST connector
14. advantages , disadvantages of medium.
15. wireless communication.
16. ground propagation, sky propagation, line of sight propagation.
17. Radio wave, micro wave
18. omni unidirectional antenna, unidirectional antenna, parabolic dish antenna, horn antenna.
19. Short note - Infrared.

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-6)

1. Def - Multiplexing process, demultiplexing process, link, carrier frequency
2. FDM , TDM , WDM, Statistical , 
3. Guard band, interleaving
4. group, super group, master group, jumbo group.
5. framing bits
6. bit padding.
7. T-lines, E-lines.
8. Inverse TDM

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-5)

1. modulation and demodulation
2. ASK,PSK,FSK,QAM -- def, diagram , example, advantages , disadvantages .
3. Bandwidth of ASK,FSK.
4. Constellation diagram
5. dibit,tribit,quadbit.
6. MODEM.
7. Modulation, demodulation.
8. AM,PM,FM -- def, diagram , example, advantages , disadvantages .
9. AM bandwidth, FM bandwidth.
10. Trellis coding.
11. minimum required bandwidth of ASK,FSK.
12. advantages of QAM and PSK over ASK
13. Frequencies use of basic telephone line.

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-4)

1. What is line coding?characteristics of line coding.
2. Signal level vs data level.
3. Pulse rate vs bit rate
4. DC component.
5. Self synchronisation.
6. unipolar , polar , bipolar line coding.
7. NRZ,RZ,Manchester, Differential manchester,NRZ-L,NRZ-I.
8. Block coding.
9. Sampling, PAM, PCM. 
10. Transmission mode.

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-3)

1. bit rate , bit synchronization.
2. what is signal?
3. What is analog signal,digital signal?
4. What is periodic signal, aperiodic signal? 
5. def-peak amplitude, time domain, frequency domain, composite signal, bandwidth.
6. Bit rate, bit interval, baud rate.
7. Low pass channel, band pass channel.
8. analog transmission, digital transmission
9. noisy channel, noise lesschannel.
10. Shannon capacity, Nyquist bit rate.
11. transmission impairement--attenuation, distortion,noise, cross-talk
12. decibel
13. throughput, propagation time, propagation speed, wavelength

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-2)

1. Network model.
2. Functions of each layer of OSI model.
3. Functions of each layer of TCP/IP model.
4. header,trailer of data.
5. framing 
6. hop-to-hop delivery, source-to-destination delivery, process-to-process delivery
7. logical addressing , routing, port address

NETWORKING FOROUZAN QUESTION SET

 Networking (Forouzan Ch-1)


1. Component of data communication..
2. Network criteria.
3. Point to point protocol, multi-point protocol
4. Various types of topology,and their advantages,disadvantages.
5. Various types of networking, and their advantages, disadvantages.
6. Difference between internet and intranet.
7. ARPANET

PROLOG PROGRAM LIST:::

1. introduction

2.arithmetic

3. if-else  - CLICK

4.loop

5. List: click

6. CBCS university assignments  CLICK

7. Read value from user:





1. BIRYINI IS A FOOD.


QUESTION:? 

A) IS BIRIYANI A FOOD?

B) IS MOMO  A FOOD?

CLICK HERE

2. 

BIRYINI IS A FOOD.

MOMO IS A FOOD.

QUESTION:? 

A) HOW MANY FOODS?

B) IF ALL FOODS ARE MEAL , THEN DISPLAY ALL MEALS.

CLICK HERE


3.

BIRYINI IS A FOOD.

MOMO IS A FOOD.

BIRIYANI IS A LUNCH.

QUESTION:? 

A) WHICH ITEMS ARE IN LUNCH?

CLICK HERE

. Print "Hello World"

Description

This program prints the message Hello World on the screen.

Program

hello :-
write('Hello World!').

Run

?- hello.

Output

Hello World!
true.

Explanation

  • hello is a predicate.
  • write() displays text on the screen.
  • :- means "is defined as".

2. Input Your Name and Print It

Description

This program accepts a user's name and prints a greeting.

Program

greet :-
write('Enter your name: '),
read(Name),
write('Hello '),
write(Name).

Run

?- greet.

Sample Input

john.

Output

Enter your name:
john.
Hello john
true.

Explanation

  • read(Name) reads input from the keyboard.
  • The entered value is stored in variable Name.
  • write(Name) displays the stored value.

3. Input Two Numbers and Display Them

Description

This program reads two numbers and displays them.

Program

display_numbers :-
write('Enter first number: '),
read(A),
write('Enter second number: '),
read(B),
write('First Number = '),
write(A),
nl,
write('Second Number = '),
write(B).

Run

?- display_numbers.

Sample Input

15.
25.

Output

Enter first number:
15.
Enter second number:
25.
First Number = 15
Second Number = 25
true.

Explanation

  • A stores the first number.
  • B stores the second number.
  • nl prints a new line.

4. Input a Number and Print Its Square

Description

This program accepts a number and prints its square.

Program

square :-
write('Enter a number: '),
read(N),
S is N * N,
write('Square = '),
write(S).

Run

?- square.

Sample Input

8.

Output

Enter a number:
8.
Square = 64
true.

Explanation

  • read(N) reads the number.
  • is evaluates arithmetic expressions.
  • S stores the square of N.

5. Input Age and Display Eligibility to Vote

Description

This program checks whether a person is eligible to vote.

Program

vote :-
write('Enter your age: '),
read(Age),
Age >= 18,
write('Eligible to vote.').

vote :-
write('Enter your age: '),
read(Age),
Age < 18,
write('Not eligible to vote.').

Run

?- vote.

Sample Input

20.

Output

Enter your age:
20.
Eligible to vote.
true.

Sample Input

15.

Output

Enter your age:
15.
Not eligible to vote.
true.

Explanation

  • >= checks if the age is 18 or more.
  • < checks if the age is less than 18.
  • Based on the condition, the appropriate message is printed.


Prolog Operators with Examples

Operators in Prolog are symbols used to perform arithmetic calculations, comparisons, logical operations, and term matching.


1. Arithmetic Operators

These operators perform mathematical calculations.

OperatorMeaningExampleResult
+AdditionX is 10 + 5.X = 15
-SubtractionX is 10 - 5.X = 5
*MultiplicationX is 10 * 5.X = 50
/DivisionX is 10 / 5.X = 2.0
//Integer DivisionX is 10 // 3.X = 3
modRemainderX is 10 mod 3.X = 1
**PowerX is 2 ** 3.X = 8.0

Example Program

calculate :-
A is 20 + 10,
B is 20 - 10,
C is 20 * 10,
D is 20 / 10,
E is 20 // 3,
F is 20 mod 3,
G is 2 ** 4,
write(A), nl,
write(B), nl,
write(C), nl,
write(D), nl,
write(E), nl,
write(F), nl,
write(G).

Output

30
10
200
2.0
6
2
16.0

2. Arithmetic Comparison Operators

These operators compare numeric values.

OperatorMeaningExampleResult
>Greater than10 > 5True
<Less than5 < 10True
>=Greater than or equal10 >= 10True
=<Less than or equal5 =< 8True
=:=Arithmetic equality5+5 =:= 10True
=\=Arithmetic inequality10 =\= 5True

Example

compare :-
X = 15,
Y = 10,
X > Y,
write('X is greater than Y').

Output

X is greater than Y

3. Unification Operators

These operators compare or assign terms.

OperatorMeaningExample
=Unify two termsX = 10.
\=Not unifiable10 \= 20.
==Exactly identical10 == 10.
\==Not identical10 \== 20.

Example

test :-
X = apple,
write(X).

Output

apple

4. Logical Operators

These operators combine conditions.

OperatorMeaningExample
,ANDA > 5, A < 20
;ORA = 5 ; A = 10
\+NOT\+ (5 > 10)

Example

check :-
X = 15,
X > 10,
X < 20,
write('Number is between 10 and 20').

Output

Number is between 10 and 20

5. Assignment Operator (is)

The is operator evaluates an arithmetic expression and assigns the result to a variable.

Syntax

Variable is Expression.

Example

square :-
N = 6,
S is N * N,
write(S).

Output

36

6. Example Program Using Multiple Operators

demo :-
write('Enter first number: '),
read(A),
write('Enter second number: '),
read(B),

Sum is A + B,
Product is A * B,

write('Sum = '),
write(Sum), nl,

write('Product = '),
write(Product), nl,

(A > B ->
write('First number is greater')
;
write('Second number is greater or equal')
).

Sample Run

?- demo.

Enter first number:
12.

Enter second number:
8.

Sum = 20
Product = 96
First number is greater

true.

Summary of Prolog Operators

CategoryOperators
Arithmetic+, -, *, /, //, mod, **
Comparison>, <, >=, =<, =:=, =\=
Unification=, \=, ==, \==
Logical, (AND), ; (OR), \+ (NOT)
Assignmentis


IF-ELSE in Prolog

Unlike languages such as C, C++, or Java, Prolog does not have a traditional if-else statement. Instead, it uses the If-Then-Else operator (-> ;).

Syntax

(Condition ->
Then_Part
;
Else_Part
).

Meaning

  • Condition → Checks the condition.
  • -> → Means THEN.
  • ; → Means ELSE.

Example 1: Check Eligible to Vote

Program

vote :-
write('Enter your age: '),
read(Age),
(Age >= 18 ->
write('Eligible to Vote')
;
write('Not Eligible to Vote')
).

Run

?- vote.

Sample Input

20.

Output

Enter your age:
20.
Eligible to Vote
true.

Sample Input

15.

Output

Enter your age:
15.
Not Eligible to Vote
true.

Example 2: Find Larger Number

Program

largest :-
write('Enter first number: '),
read(A),

write('Enter second number: '),
read(B),

(A > B ->
write('Largest Number = '),
write(A)
;
write('Largest Number = '),
write(B)
).

Sample Run

?- largest.

Enter first number:
10.

Enter second number:
25.

Largest Number = 25

true.

Example 3: Check Even or Odd

Program

evenodd :-
write('Enter a number: '),
read(N),

(N mod 2 =:= 0 ->
write('Even Number')
;
write('Odd Number')
).

Sample Output

?- evenodd.

Enter a number:
18.

Even Number

true.

Example 4: Find Positive or Negative

Program

sign :-
write('Enter a number: '),
read(N),

(N >= 0 ->
write('Positive Number')
;
write('Negative Number')
).

Output

?- sign.

Enter a number:
-8.

Negative Number

true.

Example 5: Pass or Fail

Program

result :-
write('Enter marks: '),
read(Marks),

(Marks >= 40 ->
write('Pass')
;
write('Fail')
).

Output

?- result.

Enter marks:
65.

Pass

true.

Nested IF-ELSE Example (Grade Calculator)

Program

grade :-
write('Enter marks: '),
read(M),

(M >= 90 ->
write('Grade A')
;
(M >= 75 ->
write('Grade B')
;
(M >= 50 ->
write('Grade C')
;
write('Fail')
)
)
).

Sample Run

?- grade.

Enter marks:
82.

Grade B

true.

General Syntax

predicate :-
(Condition ->
Statement1
;
Statement2
).

Difference Between C and Prolog IF-ELSE

C/C++Prolog
if(condition)(Condition -> ...)
else;
{ } blockParentheses ( )
Statement ends with ;Predicate ends with .





What is a List in Prolog?

A list is a collection of elements enclosed in square brackets [ ].

  • A list can contain numbers, atoms, variables, or even other lists.
  • Elements are separated by commas.

Syntax

[Element1, Element2, Element3, ...]

Examples

[1,2,3,4,5]

[apple, mango, orange]

[a,10,hello,25]

[]

Characteristics of a List

  • Ordered collection of elements.
  • Elements are enclosed within [ ].
  • Elements are separated by commas.
  • A list may contain duplicate values.
  • Lists can contain different data types.

Example

[10,20,30]
[apple,25,mango]
[]

Head and Tail of a List

A list consists of:

  • Head → First element
  • Tail → Remaining elements

Syntax

[Head|Tail]

Example

[10,20,30,40]

Head

10

Tail

[20,30,40]

Example Program

show :-
L = [10,20,30,40],
L = [H|T],
write('Head = '),
write(H), nl,
write('Tail = '),
write(T).

Run

?- show.

Output

Head = 10
Tail = [20,30,40]

true.

Empty List

An empty list contains no elements.

Syntax

[]

Example

empty :-
L=[],
write(L).

Output

[]

List Matching (Pattern Matching)

Prolog matches list elements using variables.

Example

match :-
[A,B,C]=[100,200,300],
write(A),nl,
write(B),nl,
write(C).

Output

100
200
300

Check Membership using member/2

The member/2 predicate checks whether an element exists in a list.

Syntax

member(Element,List)

Example

check :-
member(30,[10,20,30,40]).

Run

?- check.

Output

true.

Another Example

?- member(mango,[apple,mango,banana]).

Output

true.

Append Two Lists

The append/3 predicate joins two lists.

Syntax

append(List1,List2,Result).

Example

join :-
append([1,2,3],[4,5,6],L),
write(L).

Output

[1,2,3,4,5,6]

Length of a List

The length/2 predicate counts the number of elements.

Example

size :-
length([10,20,30,40,50],N),
write(N).

Output

5

Reverse a List

The reverse/2 predicate reverses a list.

Example

rev :-
reverse([10,20,30,40],R),
write(R).

Output

[40,30,20,10]

Sort a List

The sort/2 predicate arranges elements in ascending order.

Example

sorting :-
sort([5,2,8,1,6],L),
write(L).

Output

[1,2,5,6,8]

Find Maximum Element

maximum :-
max_list([15,28,9,45,30],M),
write(M).

Output

45

Find Minimum Element

minimum :-
min_list([15,28,9,45,30],M),
write(M).

Output

9

Sum of List Elements

sum :-
sum_list([10,20,30,40],S),
write(S).

Output

100

Nested List

Lists can contain other lists.

Example

[1,2,[3,4],5]

Another Example

[[a,b],[c,d],[e,f]]

Access Head and Tail

headtail :-
[H|T]=[apple,mango,banana,orange],
write(H),nl,
write(T).

Output

apple
[mango,banana,orange]

Generate List Members

show :-
member(X,[10,20,30]),
write(X),nl,
fail.
show.

Output

10
20
30
true.

Common Built-in List Predicates

PredicateDescriptionExample
member/2Checks whether an element existsmember(5,[1,2,5])
append/3Joins two listsappend([1],[2],L)
length/2Counts elementslength([1,2,3],N)
reverse/2Reverses a listreverse([1,2],R)
sort/2Sorts elementssort([4,2,1],L)
max_list/2Finds the largest elementmax_list([2,5,3],M)
min_list/2Finds the smallest elementmin_list([2,5,3],M)
sum_list/2Calculates the sum of elementssum_list([1,2,3],S)

Advantages of Lists

  • Easy to store multiple values.
  • Dynamic size (can grow or shrink).
  • Supports recursion efficiently.
  • Useful for searching and pattern matching.
  • Widely used in Artificial Intelligence and symbolic programming.

What is Cut (!)?

The Cut operator (!) is a special control operator in Prolog.

It is used to stop backtracking and prevent Prolog from searching for alternative solutions after the cut is reached.

Definition

The Cut (!) is a control operator that commits Prolog to the choices made before it and prevents further backtracking beyond that point.


Syntax

Predicate :-
Goal1,
Goal2,
!,
Goal3.

Why Do We Use Cut?

  • Improves program efficiency.
  • Stops unnecessary backtracking.
  • Makes the program execute faster.
  • Selects only one solution.
  • Prevents Prolog from trying other rules.

How Cut Works

Without Cut

Goal


Rule 1


Failure


Backtracking


Rule 2

With Cut

Goal


Rule 1


!


No Backtracking


Program Ends

Example 1: Simple Cut

Program

largest(X,Y,X) :-
X >= Y,
!.

largest(_,Y,Y).

Run

?- largest(20,15,R).

Output

R = 20

Explanation

  • 20 >= 15 is true.
  • Prolog reaches !.
  • Backtracking stops.
  • The second rule is ignored.

Example 2: Without Cut

largest(X,Y,X) :-
X >= Y.

largest(_,Y,Y).

Run

?- largest(20,15,R).

Output

R = 20 ;
R = 15.

Explanation

Since there is no Cut, Prolog also tries the second rule during backtracking.


Example 3: Check Positive Number

positive(X) :-
X > 0,
!,
write('Positive Number').

positive(_) :-
write('Not Positive').

Run

?- positive(15).

Output

Positive Number
true.

Another Run

?- positive(-5).

Output

Not Positive
true.

Example 4: Maximum of Two Numbers

max(A,B,A) :-
A >= B,
!.

max(_,B,B).

Run

?- max(50,20,R).

Output

R = 50

Example 5: Grade Calculator

grade(Marks) :-
Marks >= 90,
!,
write('Grade A').

grade(Marks) :-
Marks >= 75,
!,
write('Grade B').

grade(Marks) :-
Marks >= 50,
!,
write('Grade C').

grade(_) :-
write('Fail').

Run

?- grade(82).

Output

Grade B
true.

Example 6: Voting Eligibility

vote(Age) :-
Age >= 18,
!,
write('Eligible to Vote').

vote(_) :-
write('Not Eligible').

Run

?- vote(20).

Output

Eligible to Vote

Example 7: Even or Odd

evenodd(N) :-
N mod 2 =:= 0,
!,
write('Even Number').

evenodd(_) :-
write('Odd Number').

Run

?- evenodd(12).

Output

Even Number

Cut with If-Then-Else

largest :-
write('Enter First Number: '),
read(A),

write('Enter Second Number: '),
read(B),

(A > B ->
write('Largest = '),
write(A)
;
write('Largest = '),
write(B)
).

This example uses If-Then-Else (-> ;) and does not require Cut, because the conditional already commits to one branch.


Types of Cut

1. Green Cut

A Green Cut improves efficiency without changing the logical meaning of the program.

Example

max(X,Y,X) :-
X >= Y,
!.

max(_,Y,Y).

Purpose: Prevents unnecessary backtracking while preserving correct results.


2. Red Cut

A Red Cut changes the logical behavior of the program. Using or removing it may change the answers produced.

Example

grade(Marks) :-
Marks >= 40,
!,
write('Pass').

grade(_) :-
write('Fail').

Here, the cut commits to the first matching rule, affecting how later rules are considered.


Advantages of Cut

  • Stops unnecessary backtracking.
  • Makes execution faster.
  • Improves program efficiency.
  • Reduces memory usage.
  • Produces a single desired solution.
  • Simplifies control flow in some programs.

Disadvantages of Cut

  • Can make programs harder to understand.
  • May change the logical meaning if used incorrectly.
  • Makes debugging more difficult.
  • Overuse can reduce program readability.

Difference Between Cut and If-Else

Cut (!)If-Then-Else (-> ;)
Stops backtrackingSelects one branch based on a condition
Used for execution controlUsed for conditional decisions
Can affect later rule selectionDoes not rely on multiple clauses
May improve efficiencyImproves readability for conditions

Summary

SymbolMeaning
!Cut operator
PurposeStops backtracking
BenefitImproves efficiency and selects a single solution
TypesGreen Cut, Red Cut
Main UseControl execution and avoid unnecessary alternative solutions