Skip to main content

Posts

Showing posts from September, 2020

DSL D25

  Data Structure Lab : Practical C25 : A palindrome is a string of character that‘s the same forward and backward. Typically, punctuation, capitalization, and spaces are ignored. For example, “Poor Dan is in a droop” is a palindrome, as can be seen by examining the characters “poordanisinadroop” and observing that they are the same forward and backward. One way to check for a palindrome is to reverse the characters in the string and then compare with them the original-in a palindrome, the sequence will be identical. Write C++ program with functions a) To print original string followed by reversed string using stack  b) To check whether given string is palindrome or not   //Author : SPPU CSE GURU #include<iostream> #include<string> using namespace std; class Palindrome{ public: int top,max,length; char arr[100]; string data; char Pull(); Palindrome() {

Printing Name Using Symbols

  This is simple program of printing name using symbols. It just look cool to see. In this program we have simply written print function for different letters. Depending on our input it will take one by one letter and print that letter in the form of symbols. This is just for fun. #Author : SPPU CSE GURU name = input("Enter your name: ") print("\n") print("<><><><><><><><><><><><><><><><><><><><><>\n") for letter in name: letter = letter.upper() if (letter == "A"): print("..@@@@@@..\n..@....@..\n..@@@@@@..\n..@....@..\n..@....@..\n\n") elif (letter == "B"): print("..@@@@@@..\n..@....@..\n..@@@@@...\n..@....@..\n..@@@@@@..\n\n") elif (letter == "C"): print("..@@@@@@..\n..@.......\n..@.......\n..@.......\n..@@@@@@..

DSL C23

Data Structure Lab :   Practical C23 : Write C++ program for storing binary number using doubly linked lists. Write functions a) To compute 1‘s and 2‘s complement  b) Add two binary numbers The code for above problem is as follows: //Author : SPPU CSE GURU #include<iostream> using namespace std; struct dnode { int data; dnode *next; dnode *prev; }; dnode *nnode; int bit,bits,flag; class Binary{ public: dnode *head,*tail; Binary(){ head=tail=NULL; } void create(); void display(); void rdisplay(); void OneCom(); void TwoCom(); void AddNode(int x); void Addition(Binary B2); }; void Binary::create(){ cout<<"Enter total no. of bits"<<endl; cin>>bits; cout<<"***Enter bits from left to

Guessing Game

In this post there is one small easy guessing game in python language. The Guessing Game uses Binary Search Algorithm to guess the number.  How it Works It simply returns the mid value every time. It guesses the number depending on what you give input (low or high). If you give low as a input than it updates low value to mid+1 . And if you give high as a input than it updates high  to mid-1. And it will continue till your guessed number arrived. ############################################################################## #Author@SPPU CSE GURU print("Let's Play Guessing Game") def Guessing_Game(): input("Take A Number Between 1 to 100 in Your Mind and Press Enter (Don't Enter No.) ") high=100 low=0 while True: guess=(high+low)//2 print("Is Your Number",guess) res=str(input(""" Enter 'h' if Number is too high Enter 'l'

DSL C19

  Department of Computer Engineering has student's club named 'Pinnacle Club'. Students of second, third and final year of department can be granted membership on request. Similarly one may cancel the membership of club. First node is reserved for president of club and last node is reserved for secretary of club. Write C++ program to maintain club member‘s information using singly linked list. Store student PRN and Name. Write functions to: a) Add and delete the members as well as president or even secretary. b) Compute total number of members of club c) Display members d) Two linked lists exists for two divisions. Concatenate two lists. #include<iostream> using namespace std; struct node{ int PRN; char Name[10]; node *next; }; node *nnode,*npre; char ch; int prn,total=0,choice; class PinClub{ public: node *President,*Secretary;

DSL 16

Data Structure Lab : Practical B16 :   Write a Python program to store first year percentage of students in array. Write function for sorting array of floating point numbers in ascending order using quick sort and display top five scores. The Code for above problem is as follows : # sppucseguru arr=[] n=int(input("Enter Total no. of Students ")) for i in range(n): ele=float(input("Enter Percentage ")) arr.append(ele) print("Before Sorting : ",arr) def Partition(arr,low,high): pivot=arr[high] pindex=low for i in range(low,high): if arr[i]<pivot: arr[i],arr[pindex]=arr[pindex],arr[i] pindex+=1 arr[pindex],arr[high]=arr[high],arr[pindex] return pindex def QSort(arr,low,high): if low<high: pindexNew=Partition(arr, low, high) QSort(arr,low,pindexNew-1) QSort(arr,pindexNew+1,high) QSort(a

DSL 14

Data Structure Lab : Practical B14 :   Write a Python program to store first year percentage of students in array. Write function for sorting array of floating point numbers in ascending order using  a) Selection Sort  b) Bubble sort and display top five scores. #author : sppucseguru nums=[] n=int(input("Enter Total No. of Students ")) for i in range(n): ele=int(input("Enter Percentage ")) nums.append(ele) print(nums) n=len(nums) #Bubble Sort def Bubble_Sort(): swap=0 for i in range(n-1): for j in range(n-i-1): if nums[j]>nums[j+1]: nums[j],nums[j+1]=nums[j+1],nums[j] swap=1 if(swap==0): break #Selection Sort def Selection_Sort(): for i in range(n-2): min=i for j in range(i+1,n-1): if nums[j]<nums[min]: min=j if nums[min]<nums[i]: nums[i],nums[min]=nums[min],nums[i]

DSL 11

Data Structure Lab: Practical B11:   a) Write a Python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using Linear search and Sentinel search.  b) Write a Python program to store roll numbers of student array who attended training program in sorted order. Write function for searching whether particular student attended training program or not, using Binary search and Fibonacci search #author:sppucseguru A=[] while 'true' : roll= int(input ("Enter roll no. of Students who attended training program ")) A.append(roll) res=input ("Do you want to continue ? y or n ") if res=='n': break print (A) n=len(A) #linear search def LSearch(): while True: flag=0 roll= int(input ("Enter roll no. of Students which you want to check ")) f

DSL A9

  Write a Python program to compute following computation on matrix: a) Addition of two matrices B) Subtraction of two matrices c) Multiplication of two matrices d) Transpose of a matrix The Code for above problem is as follows: #@author: SPPU CSE GURU m1=int(input("Enter Number of rows for matrix A ")) n1=int(input("Enter Number of columns for matrix A ")) m2=int(input("Enter Number of rows for matrix B ")) n2=int(input("Enter Number of columns for matrix B ")) if(m1==m2 and n1==n2): A=[] for i in range(m1): sublist=[] for j in range(n1): e=int(input("Enter Element for matrix A ")) sublist.append(e) A.append(sublist) print("****** Matrix A ******") for i in A: print(i) B=[] for i in range(m2): sublist=[] for j in range(n2): e=int(input("Enter Element for matrix B "))

OOP 1

 Implement a class Complex which represents the Complex Number data type. Implement the following  1. Constructor (including a default constructor which creates the complex number 0+0i).  2. Overload operator+ to add two complex numbers. 3. Overload operator* to multiply two complex numbers. 4. Overload operators << and >> to print and read Complex Numbers. /*Implement a class Complex which represents the Complex Number data type. Implement the following operations: 1. Constructor (including a default constructor which creates the complex number 0+0i). 2. Overloaded operator+ to add two complex numbers. 3. Overloaded operator* to multiply two complex numbers. 4. Overloaded << and >> to print and read Complex Numbers.*/ //@author: SPPU CSE GURU #include<iostream> using namespace std; class complex { float real; float img; public: friend complex operator+(complex,complex

CG 2

  Write C++ program to implement Cohen Southerland line clipping algorithm. The code for above problem is as follows: //cohen-sutherland line clipping algorithm #include<iostream.h> #include<stdlib.h> #include<math.h> #include<graphics.h> #include<dos.h> typedef struct coordinate { int x,y; char code[4]; }PT; void drawwindow(); void drawline(PT p1,PT p2); PT setcode(PT p); int visibility(PT p1,PT p2); PT resetendpt(PT p1,PT p2); int main() { int gd=DETECT,v,gm; PT p1,p2,p3,p4,ptemp; cout<<"\nEnter x1 and y1\n"; cin>>p1.x>>p1.y; cout<<"\nEnter x2 and y2\n"; cin>>p2.x>>p2.y; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); drawwindow(); delay(500); drawline(p1,p2); delay(500); cleardevice(); delay(500)

CG 1

  Write C++ program to draw a concave polygon and fill it with desired colour using scan fill algorithm. Apply the concept of inheritance. The Code for above problem is as follows :  // Program to Fill a Polygon Using Scan Line Fill Algorithm in C++. #include <conio.h> #include <iostream.h> #include <graphics.h> #include <stdlib.h> #include<dos.h> class point { public: int x,y; }; class poly { private: point p[20]; int inter[20],x,y; int v,xmin,ymin,xmax,ymax; public: int c; void read(); void calcs(); void display(); void ints(float); void sort(int); }; void poly::read() { int i; cout<<"\n\t SCAN_FILL ALGORITHM"; cout<<"\n Enter the no of vertices of polygon:"; cin>>v; if(v>2) { for(i=0;i<v; i++) { cout&l