CPP Practicalsfinal
CPP Practicalsfinal
main = do
print person1
print $ firstName person1
print $ lastName person1
print $ degree person1
print $ college person1
print $ year person1
print person2
print $ firstName person2
print $ lastName person2
print $ degree person2
print $ college person2
print $ year person2
print person3
print $ firstName person3
print $ lastName person3
print $ degree person3
print $ college person3
print $ year person3
print person4
print $ firstName person4
print $ lastName person4
print $ degree person4
print $ college person4
print $ year person4
Output:
[?2004l
Person {firstName = "Janaki", lastName = "Koli", degree = "IT", college = "RIZVI", year = "2"}
"Janaki"
"Koli"
"IT"
"RIZVI"
"2"
Person {firstName = "Yashraj", lastName = "Pawar", degree = "IT", college = "XAVIER
INSTITUTE", year = "2"}
"Yashraj"
"Pawar"
"IT"
"XAVIER INSTITUTE"
"2"
Person {firstName = "Jayesh", lastName = "Rode", degree = "IT", college = "K.J.SOMAIYA",
year = "2"}
"Jayesh"
"Rode"
"IT"
"K.J.SOMAIYA"
"2"
Person {firstName = "Vaishali", lastName = "Kale", degree = "IT", college = "SHAH &
ANCHOR", year = "2"}
"Vaishali"
"Kale"
"IT"
"SHAH & ANCHOR"
"2"
[?2004h
data Month
= January | February | March | April | May | June
| July | August | September | October | November | December
deriving (Enum, Bounded, Show)
February 2023
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28
March 2023
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
April 2023
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
May 2023
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
June 2023
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
July 2023
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
August 2023
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
September 2023
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
October 2023
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
November 2023
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
December 2023
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[?2004h
Output:
[?2004l
[1,2,3,4,5,6,7,8,9,10]
("Afifah","Asmi","Reena","Kajol")
[10,9,8,7,6,5,4,3,2,1]
[110,109,108,107,106,105,104,103,102,101,100]
[2,3,4,5,6,7,8,9,10]
100
10
100
55
3628800
["GD","oa","oy","ds"]
"ComeSoon"
["Afifah","Asmi","California","Kajol","Reena"]
["Mumbai","Singapore","Paris","New York","London"]
["lion","ilon","oiln","ioln","olin","loin","noil","onil","oinl","niol","inol","ionl","nlio","lnio","lin
o","nilo","inlo","ilno","nloi","lnoi","loni","noli","onli","olni"]
1
[101,102,103,104,105,106,107,108,109,110]
10
[?2004h
main = do
print $ concat["Current " , "Balance ", "in " , "Vaishnavi Kale Account:" ]
print balance1
print $ concat["Current " , "Balance ", "in " , "Shruti Rai Account:" ]
print balance2
print $ concat["Current " , "Balance ", "in " , "Vaishnavi Kale Account:" ]
print balance3
print $ concat["Current " , "Balance ", "in " , "Shruti Rai Account:" ]
print balance4
Output:
"Current Balance in Vaishnavi Kale Account:"
2000000
"Current Balance in Shruti Rai Account:"
3000000
"Current Balance in Vaishnavi Kale Account:"
1950000
"Current Balance in Shruti Rai Account:"
3050000
Addition is 56 + 65
Addition = 121
Subtraction is 2000 - 650
Subtraction = 1350
Multiplication is 70 * 45
Multiplication = 3150
Division is 250/5
Division = 50
Power is 5 ** 10
Power = 9765625
Square is 5 ** 10
Square = 9765625
Cube is 5 ** 10
Cube = 9765625
InDiv is 5 ** 10
InDiv = 9765625
IntDiv is 5 ** 10
IntDiv = 9765625
Modulus is 550 mod 10
Modulus = 0
Modulus is 55 mod 10
R = 776,
Squareroot = 27.85677655436824
R is 726, Squareroot is sqrt(R).
R = 726,
Squareroot = 26.94438717061496
R is 786, Squareroot is sqrt(R).
R = 786,
Squareroot = 28.035691537752374
R is 729, Squareroot is sqrt(R).
R = 729,
Squareroot = 27.0
R is 675, S is 896, T is max(R,S).
R = 675,
S = T, T = 896, T is max(R,S).
R = 675,
S = T, T = 896
R is 987, S is 345, T is min(R,S).
R = 987,
S = T, T = 345
19 * 2 > 78 + 20.
false
19 * 2 =:= 30 + 8.
1true
138 * 834 =\= 102 + 820
1true
parent_of(nobita,gian).
parent_of(shizuka,suneo).
parent_of(nobita,jaiko ).
parent_of(suneo, doremon).
parent_of(miichan,doremii).
parent_of(jaiko, miichan).
father_of(X,Y):- male(X),
parent_of(X,Y).
mother_of(X,Y):- female(X),
parent_of(X,Y).
grandfather_of(X,Y):- male(X),
parent_of(X,Z),
parent_of(Z,Y).
grandmother_of(X,Y):- female(X),
parent_of(X,Z),
parent_of(Z,Y).
sister_of(X,Y):-
female(X),
father_of(F, Y), father_of(F,X),X \= Y.
sister_of(X,Y):- female(X),
mother_of(M, Y), mother_of(M,X),X \= Y.
aunt_of(X,Y):- female(X),
parent_of(Z,Y), sister_of(Z,X),!.
brother_of(X,Y):-
male(X),
father_of(F, Y), father_of(F,X),X \= Y.
brother_of(X,Y):- male(X),
mother_of(M, Y), mother_of(M,X),X \= Y.
uncle_of(X,Y):-
parent_of(Z,Y), brother_of(Z,X).
Output:
mother_of(X,Y)
X = shizuka,
Y = suneo
X = miichan,
Y = doremii
X = jaiko,
Y = miichan
father_of(X,Y)
X = nobita,
Y = gian
X = nobita,
Y = jaiko
X = suneo,
Y = doremon
grandfather_of(X,Y)
X = nobita,
Y = miichan
grandmother_of(X,Y)
X = shizuka,
Y = doremon
X = jaiko,
Y = doremii
sister_of(X,Y)
X = jaiko,
Y = gian
brother_of(X,Y)
X = gian,
Y = jaiko
brother_of(X,Y)
X = gian,
Y = jaiko
uncle_of(X,Y)
false
aunt_of(X,Y)
false
list_delete(X,[X], []).
list_delete(X,[X | L1], L1).
list_delete(X,[Y | L2], [Y | L1]):- list_delete(X, L2, L1).
list_concat([], L, L).
list_concat([X1 | L1], L2,[X1 | L3]):- list_concat(L1, L2, L3).
list_rev([], []).
list_rev([Head|Tail], Reversed):- list_rev(Tail, RevTail),
list_concat(RevTail, [Head], Reversed).
insert_at_end(L, X, NewList) :-
join_list(L, [X], NewList).
dividing_list([],[],[]).
dividing_list([X],[X],[]).
dividing_list([X,Y|Tail], [X|List1],[Y|List2]) :-
dividing_list(Tail,List1,List2).
Output:
list_length([a,b,c,g,y,f],Length).
Length = 6
list_delete(b,[a,b,c,g,y,f],New_List).
New_List = [a, c, g, y, f]
list_rev([p,p,a,s,t,a,h,w],Reversed).
Reversed = [w, h, a, t, s, a, p, p]
join_list([ram,sham],[magan,jagan], Combined_List).
Combined_List = [ram, sham, magan, jagan]
insert_at_end([320,325,339],345,ElementAddedAtLast).
ElementAddedAtLast = [320, 325, 339, 345]
dividing_list([1,b,4,f,6,y,9,j,3,d,5,u],Numbers,Letters).
Letters = [b, f, y, j, d, u],
Numbers = [1, 4, 6, 9, 3, 5]
Output:
merge_sort([20, 56, 46, 10, 1 34], Sorted).
Sorted = [10, 20, 46, 56, 134]
false
merge_sort([1967, 2005,1990,2024], Sorted).
Sorted = [1967, 1990, 2005, 2024]
false
% Sample facts
friend(alice, bob).
friend(bob, charlie).
Output:
list_friends
false
remove_friend(alice, bob)
1true
add_friend(ritik,rahul)
1true
Output:
list_friends.
ari is friends with ankita
kumud is friends with vrushali
yash is friends with jay
janhavi is friends with vaishnavi
1true
Program:
:- dynamic(friend/2).
% Sample facts
friend(yash, jay).
friend(janhavi, vaishnavi).
% Add a new friend at the beginning of the list
add_friend(X, Y) :-
assertz(friend(X, Y)).
% List all friends
list_friends :-
friend(X, Y),
format('~w is friends with ~w~n', [X, Y]),
fail.
list_friends.
?- add_friend(kumud, vrushali).
?- add_friend(ari, ankita).
Output:
list_friends.
yash is friends with jay
janhavi is friends with vaishnavi
kumud is friends with vrushali
ari is friends with ankita
1true