Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1896 of 2650
10K+ Views
Time complexity of any algorithm is the time taken by the algorithm to complete. It is an important metric to show the efficiency of the algorithm and for comparative analysis. We tend to reduce the time complexity of algorithm that makes it more effective.Example 1Find the time complexity of the following code snippetsfor(i= 0 ; i < n; i++){ cout
8K+ Views
Precision of floating point numbers is the accuracy upto which a floating point number can hold the values after decimal. For example, 10/6 = 1.6666666… these have recurring decimals which can take infinite memory spaces to be stored. To avoid memory overflow in such cases the compiler set a precision limit to the number. For float values in C++, the precision is set to 6-7 digit after that if the decimal recurs it will discard the value. So, to avoid any major losses when this discarding takes place there are methods and libraries that support the precision is float values. ... Read More
2K+ Views
Identifier is the name given to an entity in programming to identify it in the program.Generally, identifiers are created by the programmer for efficient working but there are some predefined identifiers that are inbuilt in programming. For example, cout, cin, etc.Here, we will see one of these predefined identifiers of C programming language which is __func__.The formal definition of __func__ is −“The identifier __func__ shall be implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declarationstatic const char __func__[] = “function-name”;appeared, where function-name is the name of the lexically-enclosing function.”C program The ... Read More
2K+ Views
Taking advantage of the for loop and range function in python, we can draw a variety of for pyramid structures. The key to the approach is designing the appropriate for loop which will leave both vertical and horizontal space for the position of the symbol we choose for drawing the pyramid structure.Pattern -1We draw a right angle based pattern.Example Live Demodef pyramid(p): for m in range(0, p): for n in range(0, m+1): print("* ", end="") print("\r") p = 10 pyramid(p)OutputRunning the above code gives us the following result −* * ... Read More
348 Views
In this game, there are two players X and Y. our task is to predict who will win the game if both play optimally and X starts the game.GameIn the coin game, there are two piles with N and M number of coins. One of the players chooses any one of the piles for the game. Then the task is to divide the piles into two halves till any one player cannot further divide the piles.Let’s take an example to understand the problem, Input: M = 2 , N = 2 Output:XExplanation - X starts the game and choose M pile(both ... Read More
190 Views
In this problem, we are given an array of n numbers. And there are two players X and Y. Our task is to predict the winner of the game.For player X to win the absolute difference of the sum of numbers by X and Y should be a multiple of 4. If it is not divisible by 4, then Y wins. Player X starts the game.Let’s take an example to understand the problem, Input: a[] = {3 6 9 12} Output: X Explaination: X selects 3 and 6 Y selects 12 and 9 |3+6 - 12+9| = 12, 12 is ... Read More
3K+ Views
Python’s libraries to draw graphs has very extensive features which can not only give us charts but also give us flexibility to draw other diagrams like flags. In that sense those modules have an artistic touch. In this article we will see how to draw the Indian flag using the libraries numpy and matplotlib.AppraochWe create three rectangles of same width and draw them with appropriate colours and borders.Use pyplot function to draw the circle of the Ashok Chakra at the center of the middle rectangle.Use numpy and matplotlib to draw the 24 lines inside the Ashok Chakra.In all the above ... Read More
4K+ Views
In this problem, we are given a 2D array of integer values mat[][]. Our task is to print the prefix sum matrix of mat.Prefix sum matrix: every element of the matrix is the sum elements above and left of it. i.eprefixSum[i][j] = mat[i][j] + mat[i-1][j]...mat[0][j] + mat[i][j-1] +... mat[i][0].Let’s take an example to understand the problemInput: arr =[ [4 6 1] [5 7 2] [3 8 9] ] Output:[ [4 10 11] [9 22 25] [12 33 45] ]To solve this problem, ... Read More
2K+ Views
In Academics it is a common requirement to find the grades of students after an assessment. In this article we will create a Python program which will assign the grades based on the grading criteria. Will call it A grade calculator.Grading criteriaBelow is the grading criteria we have chosen for the program.score >= 90 : "O" score >= 80 : "A+" score >= 70 : "A" score >= 60 : "B+" score >= 50 : "B" score >= 40 : "C"Program ApproachInitialize variables and array to hold the student details including the marks obtained by individual subjects.Define a function to ... Read More
500 Views
Many times the numbers with three or more digits need to be represented suitably using comma. This is a requirement mainly in the accounting industry as well as in the finance domain. In this article we'll see how Python program can be used to insert a comma at a suitable place. We are aiming to insert comma as a thousand separator.Format FunctionThe format function in python can be used with below settings to achieve this requirement.(f"{num:, d}") : is the format specifier D is the thousand separatorExample - Integers Live Demoprint(f'{1445:, d}') print(f'{140045:, d}')OutputRunning the above code gives us the following ... Read More