Posts

Showing posts from April, 2023

Shivam Dixit

Image
 

SIGFPE - SIG Floating point Error : Cause, Resoultion, Means

 Floating Point Operation it is a measurement of accuracy the term FPO used most in scientific calculations SIGFPE - This error signal denotes some arithmetic error that occurred like division by zero, or floating-point error. If a program stores integer data in a location that is then used as a floating-point operation, this causes an “invalid operation” exception as the processor cannot recognize the data as a floating-point value. But this signal does not specify the type of floating-point error.    Basically, check your looping statement either it does not divide your value with 0

Why do we use "Using namespace std;" in cpp

what is the use of  Namespace & What is namespace or namespace std; in c++:  it is a special feature introduced in cpp, and with its help, we can prevent duplication in the program of variables and especially of methods(Functions()) For Ex, if we working with any xyz() and it is also present in the standard library then compiler gets exerts an error to us due duplicate function in the same directory  but with the use of it, we can overcome this error  Namespaces allow us to group named entities that otherwise would have  global scope  into narrower scopes, giving them  namespace scope . This allows organizing the elements of programs into different logical scopes referred to by names. Namespaces provide the space where we can define or declare identifiers i.e. names of variables, methods, classes, etc. Why do we use using namespace std; first, we should know what is the use of it  by this, we tell the compiler that we are using all the entities present in the particular directive(s

Given a string str consisting of only two characters 'a' and 'b'. You need to find the minimum steps required to make the string empty by removing consecutive a's and b's

 Question:  Given a string  str  consisting of only two characters  'a'  and  'b' . You need to find the minimum steps required to make the string empty by removing consecutive  a's  and  b's My CODE(Shows RUNTIME ERROR(take more time than expected)): #include <iostream> #include <string> using namespace std; int ForB(string str,int sizeA,int countA=0,int i=0){     /*if(i==sizeB){         return countB;     }*/      while(i!=sizeA){     if (str[i]=='b' || str[i]=='B'){       if(i!=sizeA-1){         str[i]='X';}       else if (i==sizeA-1){           str[i]='X';           countA++;       }       i++;}       else if((str[i]!='a'||str[i]!='A')&&(/*str[i-1]=='a'||*/  str[i-1]=='X')){         countA++; i++;        }   }   return countA; } int ForA(string str,int sizeA,int countA=0,int i=0){    /* if(i==sizeA){         return countA;     }*/   while(i!=sizeA){     if (str[i]=='a'

#include : Advantages and Disadvantages

Image
 #include <bits/stdc++.h> : Advantages and Disadvantages introduction : It is the header file that prevents chores and helps us to make our coding fast by excluding specific use of header files likewise by including only this file we can use vectors, strings and math operation  and get saves to use a bunch of lines of code  Advantages : This helps when we want to get a high rank in time limit-based coding competition  We don't need to remember lots of the header files  Prevent chores(unwanted jobs) Disadvantages : Due to including all the header files by   #include <bits/stdc++.h>            The compilation time gets increased The size of the file also gets increased  Not considered to be a good practice On every line of need, all headers are in action and the function chooses a specific header file according to the need Can not use this in MSVC(Micro Soft Visual Code) but can in GCC
 int x=1;        vector<int> v;         vector<vector<int> > ans;         int start,end;         for (int i=0;i<n;i++){             if(A[i]<A[i+1]){                 start = i;                 end=endpoint(A,n);                 i=end;                 v.push_back(start);v.push_back(end);                 ans.push_back(v);             }         return ans;

vector & pair : Introduction, Use, Example, Implementation, question

Image
 Vectors and pairs  Vectors vectors Introduction : Vector is an advanced form of an array or can say it is the resolution of drawbacks of arrays while we use it  , if we talk about a definition so; a Vector is a form of an array with a special functionality in this we don't want to pre-define the size of the Vectors, but in the case of the array we need to define the size of this feature makes a vector Dynamic type Vector Definition or what is a vector, answer: A vector is the type of array that automatically define its size along with use or in run time Use : We use vectors when there is no proper surety of the size of the Array Example : if we want to make a dynamic array that automatically states its size ; #include <iostream> #include <vector> int main(){           vector<int> v;           //here v is int type data storing vector            v[0]=433;           v[1]=43;                   // NOTE: We do not define the size of it           cout<<v[1]&

Pageviews