You are on page 1of 15

1.

Title
: TO STUDY AND IMPLEMENT CONJUNCTION, DISJUNC-
TION AND NEGATION.

2. Objectives:
 To verify and implement conjunction using c program.
 To verify and implement disjunction using c program.
 To verify and implement negation using c program.

3. Theory:

A conjunction is a compound statement formed by joining two statements with the connector
AND. The conjunction "p and q" is symbolized by p q. A conjunction is true when both of its
combined parts are true, otherwise it is false.
Truth table :
p q p^q
T T T
T F F
F T F
F F F

A disjunction is a compound statement formed by joining two statements with the connector OR.
The disjunction "p or q" is symbolized by p q. A disjunction is false if and only if both
statements are false; otherwise it is true. The truth values of p q are listed in the truth table
below.
p q pvq
T T T
T F T
F T T
F F F

The negation of statement p is "not p." The negation of p is symbolized by "~p." The truth value
of ~p is the opposite of the truth value of p.The truth table is shown below.
p ~p

T F
F T
4. Implementation with C.
4.1.1: Program to demonstrate conjunction.
4.1.2: Source Code:
#include<stdio.h>
void main()
{
char p[] = {'T', 'T','F','F'};
char q[]={'T','F','T','F'};
char r[5];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<4; i++)
{
if(p[i]=='T'&&q[i]=='T')
{ r[i]='
T';
}
Else
{ r[i]='
F';
}
}
for(i= 0; i<4; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}
4.1.3: Output

4.2.1: To demonstrate disjunction.


4.2.2: Source Code:
#include<stdio.h>
void main()
{
char p[] = {'T', 'T','F','F'};
char q[]={'T','F','T','F'};
char r[5];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<4; i++)
{
if(p[i]=='F'&&q[i]=='F')
{
r[i]='F';
}
else{
r[i]='T';
}
}
for(i= 0; i<4; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}

4.2.3: Output:

4.3.1: To demonstrate negation.


4.3.2: Source Code:
#include<stdio.h>
void main()
{
char p[] = {'T', 'F'};
char r[5];
int i = 0;
printf("p\tr\n");
printf(" \n");
for(i= 0; i<2; i++)
{
if(p[i]=='T')
{
r[i]='F';
}
Else
{
r[i]='T';
}
}
for(i= 0; i<2; i++){
printf("%c\t%c\n", p[i], r[i]);
}
}

4.3.3: Output:

5. Output & Discussion:

In first program we can see that the output of the conjunction is true only when the both
the input is true.We implemented the conjunction using c program and the output of the c
program shows the truth table of conjunction.Similarly in second and third program we
can see the output provides the truth table of the disjunction and negation.

6. Conclusion:

In this way we studied and implemented the conjunction, disjunction and negation using
c program.
1. Title:
TO STUDY AND IMPLEMENT IMPLICATION AND
BICONDITION.

2. Objective:
 To verify Implication.
 To verify bicondition.

3. Theory:
An implication is the compound statement of the form “if pp, then qq.” It is denoted p⇒q, which
is read as “p implies q.” It is false only when p is true and q is false, and is true in all other
situations.
Truth table:
p q p⇒q
T T T
T F F
F T T
F F T

The biconditional statement “p if and only if q,” denoted p⇔q, is true when both p and q carry
the same truth value, and is false otherwise. It is sometimes abbreviated as “p iff q.”

p q p⇔q
T T T
T F F
F T F
F F T

4. Implementing using C.
4.1.1:Program to demonstrate
Implication. 4.1.2: Source Code:
#include<stdio.h>
void main()
{
char p[] = {'T', 'T','F','F'};
char q[]={'T','F','T','F'};
char r[5];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<4; i++)
{
if(p[i]=='T'&&q[i]=='F')
{ r[i]='
F';
}
else
{ r[i]='
T';
}
}
for(i= 0; i<4; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}

4.1.3:Output:
4.2.1: To demonstrate bicondition.
4.2.2:Source code:
#include<stdio.h>
void main()
{
char p[] = {'T', 'T','F','F'};
char q[]={'T','F','T','F'};
char r[5];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<4; i++)
{
if(p[i]==q[i])
{ r[i]='
T';
}
else
{ r[i]='
F';
}
}
for(i= 0; i<4; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}

4.2.3: Output:

5. Output and discussion:


By implementing the implication and the bicondition using c program we got the output as the
truth table of implication and bicondition respectively. In implication the result is false if p is
true and q is false where as in bicondition the output is true if and only if p and q are same.

6. Conclusion:
From above practical we can conclude that the value of implication is false if p is true and q is
false and the value of bicondition is true for both value of p and q are equal.
1. Title:
TO STUDY AND TO IMPLEMENT TAUTOLOGY,
CONTRADICTION AND CONTENGENCY.

2. Objective:
 To study about tautology and implement it using c program.
 To study about contradiction and implement it using c program.
 To study about contingency and implement it using c program.

3. Theory:
Tautology is a compound proposition which remains always true, no mater what the truth value
of proposition variables is. For example (P P) is always true regardless of the value of
the proposition P.
Contradiction is a compound proposition which remains always false, no matter what the truth
value of variable is. For example (P ^ P) is always false regardless of the value of the
proposition P.
Contingency is a compound preposition which neither is a tautology nor a contradiction . For
example (P Q) is a contingency.
4. Implementing using C.
4.1.1: To demonstrate tautology.
4.1.2: Source Code:
#include<stdio.h>
void main()
{
char p[] = { 'T','F'};
char q[]={'F','T'};
char r[3];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<2; i++)
{
if(p[i]==q[i])
{ r[i]='
T';
}
else
{ r[i]='
T';
}
}
for(i= 0; i<2; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}

4.1.3: Result:

4.2.1: To demonstrate contradiction.


4.2.2: Source Code:
#include<stdio.h>
void main()
{
char p[] = { 'T','F'};
char q[]={'F','T'};
char r[3];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<2; i++)
{
if(p[i]==q[i])
{ r[i]='
F';
}
else
{ r[i]='
F';
}
}
for(i= 0; i<2; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}

4.2.3: Output:
4.3.1: To demonstrate
contingency. 4.3.2: Source code:
#include<stdio.h>
void main()
{
char p[] = {'T', 'T','F','F'};
char q[]={'T','F','T','F'};
char r[5];
int i = 0;
printf("p\tq\tr\n");
printf(" \n");
for(i= 0; i<4; i++)
{
if(p[i]=='T'&&q[i]=='T')
{ r[i]='
T';
}
Else
{ r[i]='
F';
}
}
for(i= 0; i<4; i++)
{
printf("%c\t%c\t%c\n", p[i],q[i], r[i]);
}
}
4.3.3: Output:

5. Output and discussion:


By implementing the tautology, contradiction and contingency using c program we can see that
the result of tautology is always true no mater the truth value of the variable where as the
contradiction is opposite to the tautology and the result of the contradiction is always false. In
contingency we can see the result is neither always true nor always false.

6. Conclusion
We can conclude that tautology is always true, contradiction is always false and contingency is
neither tautology is nor contradiction.
INDE
X
SUBJECT: ROLL NO:

SN TITLE DATE SIGNATURE REMARKS


NO.

You might also like