Skip to main content

Posts

Showing posts with the label C++

Transfer google play balance to Paytm, PhonePe, Google Pay or any UPI linked bank account.

To transfer google play balance, opinion rewards or gift cards to PayPal, Paytm, PhonePe, Google Pay or any UPI ID linked bank account , you can use QxCredit :Rewards Convertor app which is available on google play store: You will get back 80% of the google play balance. App link:  https://play.google.com/store/apps/details?id=qxcoding.qx_credit_reboot Follow these steps to transfer your play balance to paypal or UPI: 1) download app from play store. 2) login with your google account and phone number. 3) choose a token amount which you want to convert/transfer. 4) Enter your payout details.(UPI ID or PayPal Email) 5) wait for an acknowledgement mail form qxcredit containing information about your purchased token. 6) you will receive the amount within 3 days. 7) if you face any issues you can raise a query on website: https://qx-credit.web.app/#/contact_support About app: Introducing QxCredit : Rewards Converter Convert /Transfer or Exchange your Google Play Balance and opini...

What is the difference between a Vector and an Array. Discuss the advantages and disadvantages of both?

Differences between a Vector and an Array - A vector is a dynamic array, whose size can be increased, where as an array size can not be changed. - Reserve space can be given for vector, where as for arrays can not. - A vector is a class where as an array is not. - Vectors can store any type of objects, where as an array can store only homogeneous values. Advantages of Arrays: - Arrays supports efficient random access to the members. - It is easy to sort an array. - They are more appropriate for storing fixed number of elements Disadvantages of Arrays: - Elements can not be deleted - Dynamic creation of arrays is not possible - Multiple data types can not be stored Advantages of Vector: - Size of the vector can be changed - Multiple objects can be stored - Elements can be deleted from a vector Disadvantages of Vector: - A vector is an object, memory consumption is more.   if any doubts or queries please comment 

Demonstration of new data types using structures

What is a structure? A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type. How to create a structure? ‘struct’ keyword is used to create a structure. Following is an example. the below example demonstrates the creation of new data type point which can store coordinates : // A variable declaration with structure declaration. struct Point { int x, y; } p1; // The variable p1 is declared with 'Point' for using the above structure we need to use structure_name (.) member access operator followed by a member name of defined structure. int main() { // A valid initialization. member x gets value 0 and y // gets value 1. The order of declaration is followed. struct Point p1 = {0, 1}; cout<<"value of x="<<p1.x<<"value of y="<<p1.y; }   if any doubts or queries please comment 

c++ typing speed tester project using graphics.h header file

INTRODUCTION I have made project “ Typing speed tester “. In this software we can test our speed and efficiency for typing via general keyboard. In this programme we have to type the characters which are displayed on the user screen. Now, coming to technical aspects of this software, all data are maintained in binary files, concepts of function and little bit use of graphical colours. LOGIN   INFORMATION USERNAME:    jatin PASSWORD:    password Header Files Ø iostream.h Ø dos.h Ø stdio.h Ø conio.h Ø time.h Ø string.h Ø stdlib.h Ø "tt.h" SOFTWARE RECQURIMENTS OS:             Windows Platform RAM :           512 MB Processor :   Pentium 3 or Above Compiler :     Turbo C++      or                       Borland C...

How to convert binary number to decimal number using recursion in C

Recursive function: int binary(int num,int step){ if(!num){ return num; } printf("step %d: binary no=%d,rem=%d \n",step,num,num%10); num=num%10+2*binary(num/10,step+1); printf("backtrack res step %d (decimal)=%d\n",step,num); return num; } the above function recursively calls itself by passing the binary number whose last digit is removed and stored in num%10 (remainder) which will be added and multiplied by two in each phase while backtracking. num=num%10+2*binary(num/10,step+1); the output of the code along with the values of variables in forward and backward stage are given below: Source Code: // https://www.qxcoding.com/ //binary to decimal include int binary(int num,int step){ if(!num){ return num; } printf("step %d: binary no=%d,rem=%d \n",step,num,num%10); num=num%10+2*binary(num/10,step+1); printf("backtrack res step %...

How to merge two sorted singly linked list

here we will discuss ,how to merge two sorted linked list such that the final list is sorted in ascending order the structure ( node ) definition is given below: typedef struct node{ int val; struct node* next; }* node; Explanation: we will insert (merge ) the elements of list 2 (f2) in f1 by comparing each nodes value. ALGORITHM: traverse both lists till one of them is completely traversed compare the values of node and if the value of node of list f1 is smaller then move to next node of f1 and increment the value of pos. the pos variable will be used after complete traversal to join the remaining elements of f2 if any. and if f2 nodes value is smaller then insert it before the current node in f1 and set f1 to previous node that is the node of f2 and increment f2 to next node. after completely traversing one of the lists , append the remaining elements of f2 if any in f1 . void merge_ll(node *first){ delete_ll(*first);*first=NULL; int pos=0; printf(...

How to Reverse a Singly linked list ? C/C++ Program

To reverse a given linked list ,we have to point the next (link) of each node to its previous node(ie: the node which is pointing to it.) for that we will maintain three pointers : 1) prev : will point to the node which is pointing to the current node. 2) cur : will point to the node in which we have to change the next(link) to the previous node. 3) next: in the process of changing the cur->next to prev the           cur->next will be lost so to store the address of cur->next we use next pointer. Node definition: typedef struct node{ int val; struct node* next; }* node; as given above the node contains two members value and a pointer pointing to its own datatype which will store the address of another node . reverse_ll(node *first) : function : void reverse_ll(node* first){ node prev=NULL; node cur=(*first); node next=NULL; while(cur){ next=cur->next; cur->next=prev; pr...

How to find the occurrence's of a pattern in a given string Using KMP algorithm?

For finding the pattern in a given string , we are going to use KMP algorithm for individual occurrence of the pattern and print the reference index of the original string. The function which will find the pattern in a given string : int KMP(char * str,char* find,int s){ int sl=strlen(str); int fl=strlen(find); for(int i=s;i<sl-fl+1;i++){ int i1=i; for(int j=0;j<fl;j++,i1++){ //cout<<j<<fl<<endl; if(j==fl-1)return i; if(str[i]!=find[j])break; } } return -1; } For finding all the places (positions/index) where the pattern is present, we have to call the above function repetitively with passing the index from where it has to resume the search as a parameter to the function. The same is implemented in the function below: int print_occurence(char* str,char* find){ int sl=strlen(str); int fl=strlen(find); int occ=0; for(int i=0;i<sl;i++){ ...

How to create a Binary Tree Program ( Python / C / C++ )

What is a binary tree? A binary tree is categorized as an abstract data type , whose (I/O) ,(R/W) operations are handled by the user defined functions.A binary tree is a special case of a tree DS where each node except leaf nodes has two children's . for creating a binary tree we will define a class / structure node which will contain the members(left child and right child) and the value. class node: def __init__(self, value=None): self.value = value self.left_child = None self.right_child = None Now , we will write the code for inserting elements in our binary tree, we will create the function in another class containing a member which will store the address of root node and add all successive elements under the root node . def insert(self, value): if self.root == None: self.root = node(value) else: self._insert(value, self.root) def _insert(self, value, cur_node): if value ...

How to find and replace a node in Linked List

For replacing an element in a linked list first we have to find it , for that we will use a function which will do the finding part and give us the node's address (pointer) and then we will replace the value of that node by the value given by the user. Definition of node* find_pos(int) function node* find_pos(int val,int p){ node* cur=first; node* prev=cur; while(cur->val!=val){ prev=cur; cur=cur->next; if(cur==NULL)return NULL; } switch(p){ case 0: return cur; case 1: return cur->next; default:return prev; } } The above function keeps track of the previous node and keep traversing through the linked list until we find the value which is to be replaced, it return the previous node if value of p is -1 or returns current node if p=0 or next one if p=1. Definition of find_replace function void find_replace(int find,int replace){ int c=0; while(node *temp=find_pos(find,0)...

How to Insert ,Delete ( first or last ) nodes in Linked List C / C++

Node definition (Structure) : struct node{ int num; node* next; }; The num variable stores the data given by the user and the pointer (next) stores the address of the next element present in the linked list. Insertion of Nodes : 1) Inserting in beginning :  void insert_beg(int value){ node* n=new node; n->num=value; if(first==NULL){ n->next=NULL; first=n; } else{ n->next=first; first=n; } } the above function ,when called creates a new node and stores the value passed to it in num (variable) ,now the function checks if the list is empty and if it is empty then it is simply marked as the first element in the linked list. if the list is not empty then the pointer (next ) is assgned to the first element address and the marker (first) is given to current element. 2) Insertion at end :  void insert_end(int value){ node* n=new node; n->num=value; n-...

How to Insert ,Delete nodes in between the Linked List

Node definition (Structure) : struct node{ int num; node* next; }; The num variable stores the data given by the user and the pointer (next) stores the address of the next element present in the linked list. Insertion in between nodes (After a given node ) : void insert_inBetween(){ int cvalue,value; cout<<"Enter the value after which you want to insert the new node"<<endl; cin>>cvalue; cout<<"enter the value of new node: "; cin>>value; cout<<endl; node *n,*prev; n->num=value; if(prev=find(cvalue,0)){ n->next = prev->next; prev->next=n; cout<<"node inserted succesfully"; } else{ cout<<"Node value not found"; } } for performing the insertion after an element given by the user , we need to know the location of the node after which it is to be inserted, for this another function (find()) will be called which will return the address of the node af...