Skip to main content

The Fundamentals of Digital Marketing Certification

The Fundamentals of Digital Marketing Certification
Trying to make use of some spare time during these endless lockdowns. I completed The Fundamentals of Digital Marketing course on Google Digital Garage and got certified. This is not a great victory, nevertheless, I celebrate every small step towards a greater goal. #googlegarage #fundamentalsofdigitalmarketing #digitalmarketing

FDS 9

 Practical No: -9

Experiment No. 9: 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 “poor danisina droop” 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 functionsa) To print original string followed by reversed string using stack

b) To check whether given string is palindrome or not

Code:

#include<iostream>

#include<string.h>

#define max 50

using namespace std;

class STACK

{

 private:

 char a[max];

 int top;


 public:

 STACK()

 {

 top=-1;

 }


 void push(char);

 void reverse();

 void convert(char[]);

 void palindrome();

};

void STACK::push(char c)

{

 top++;

 a[top] = c;

 a[top+1]='\0';


 cout<<endl<<c<<" is pushed on stack ...";

}

void STACK::reverse()

{

 char str[max];


 cout<<"\n\nReverse string is : ";


 for(int i=top,j=0; i>=0; i--,j++)

 {

 cout<<a[i];

 str[j]=a[i];

 }


 cout<<endl;

}

void STACK::convert(char str[])

{

 int j,k,len = strlen(str);

 for(j=0, k=0; j<len; j++)

 {

 if( ( (int)str[j] >= 97 && (int)str[j] <=122 ) || ( (int)str[j] >= 65 && (int)str[j] <=90 ))

 {

 if( (int)str[j] <=90 )

 {

 str[k] = (char)( (int)str[j] + 32 );

 }else

 {

 str[k] = str[j];

 }

 k++;

 }

 }

 str[k]='\0';

 cout<<endl<<"Converted String : "<<str<<"\n";

}

void STACK::palindrome()

{

 char str[max];

 int i,j;

 for(i=top,j=0; i>=0; i--,j++)

 {

 str[j]=a[i];

 }

 str[j]='\0';



 if(strcmp(str,a) == 0)

 cout<<"\n\nString is palindrome...";

 else

 cout<<"\n\nString is not palindrome...";

}

int main()

{

 STACK stack;

 char str[max];

 int i=0;


 cout<<"\nEnter string to be reversed and check is it palindrome or not : \n\n";


 cin.getline(str , 50);


 stack.convert(str);


 while(str[i] != '\0')

 {

 stack.push(str[i]);

 i++;

 }

 stack.palindrome();

 stack.reverse();


}

Output:

Poor Dan is in a Droop

Converted String : poordanisinadroop

p is pushed on stack ...

o is pushed on stack ...

o is pushed on stack ...

r is pushed on stack ...

d is pushed on stack ...

a is pushed on stack ...

n is pushed on stack ...

i is pushed on stack ...

s is pushed on stack ...

i is pushed on stack ...

n is pushed on stack ...

a is pushed on stack ...

d is pushed on stack ...

r is pushed on stack ...

o is pushed on stack ...

o is pushed on stack ...

p is pushed on stack ...

String is palindrome...

Reverse string is : poordanisinadroop

--------------------------------

Process exited after 11.85 seconds with return value 0

Press any key to continue . . . 

GALLERY

GALLERY
photos

ABOUT

HTML CSS, VB.net Developer and Java, C programming. With Loves Problem Solving and to Unreval the Mysteries behind the Magic of Computer Programming

Followers

MY PROJECTS

Popular posts from this blog

FDS 12

 Practical No: -12 Experiment No. 12: A double-ended queue(deque) is a linear list in which additions and deletions may be made at either end. Obtain a data representation mapping a deque into a one-dimensional array. Write C++ program to simulate deque with functions to add and delete elements from either end of the deque. Code: using namespace std; #include<iostream> #include<stdio.h> #include<process.h> #define MAX 30 typedef struct dequeue {  int data[MAX];  int rear,front; }dequeue; void initialize(dequeue *p); int isEmpty(dequeue *p); int isFull(dequeue *p); void enqueueRear(dequeue *p,int x); void enqueueFront(dequeue *p,int x); int dequeueFront(dequeue *p); int dequeueRear(dequeue *p); void display(dequeue *p); main() {  int i,x,choice,n;  dequeue q;  initialize(&q);  do  {  cout<<"\n 1.Create \n 2.Insert(rear) \n 3.Insert(front) \n 4.Delete(rear) \n 5.Delete(front)";  cout<<"\n 6.Display \n 7.Ex...

dsa

 https://drive.google.com/drive/folders/1xaWUPlioGjpK0WAmAD-mvlxAuA8eTK1c https://github.com/khan0003-py/SPPU-Computer-4th-Sem-Lab-Codes/tree/master/DSAL

FDS 11

 Practical No: -11 Experiment No. 11: Queues are frequently used in computer programming, and a typical example is the creation of a job queue by an operating system. If the operating system does not use priorities, then the jobs are processed in the order they enter the system. Write C++ program for simulating job queue. Write functions add job and delete job from queue. Code: using namespace std; #include<iostream> #include<stdio.h> #include<conio.h> #include<stdlib.h> #define SIZE 5 void enqueue(int x); void dequeue(); void display(); int FRONT=-1; int REAR=-1; int QUEUE[SIZE]; main() {  int x,ch;  while(1)  {  cout<<"\n 1:Add Job";  cout<<"\n 2:Delete Job";  cout<<"\n 3:Display";  cout<<"\n 4:Exit";  cout<<"\n Enter Your Choice:";  cin>>ch;  switch(ch)  {  case 1:  cout<<"Enter Job:";  cin>>x;  enqueue(x);  break;  case 2: ...

Contact us

Name

Email *

Message *