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
Programming Articles - Page 915 of 3363
775 Views
We will understand how C and C++ behave differently in case we re-declare a global variable without initializing, redeclaring global variables with initialization, redeclaring global variables and initializing them twice. Also, we will repeat above combinations with local variables.1. A) C program : Redeclaring Global variables with no initialization#include int var; int var; int main(){ printf("Var = %d",var); return 0; }OutputVar = 0B) C++ program : Redeclaring Global variables with no initialization#include using namespace std; int var; int var; int main(){ cout
281 Views
To find the frequency of non-NA values in each row of an R data frame, we can use apply function along with na.omit function.For Example, if we have a data frame called df that contains some NA values then we can find the frequency of non-NA values in each row of df by using the command as follows −apply(df,1, function(x) length(na.omit(x)))Example 1Following snippet creates a sample data frame −x1
8K+ Views
Selection Sort is one of the sorting algorithms used to sort data by iterating an array from the beginning and replacing each element with the smallest element in the list. As we move forward the left array is sorted, and the right array is unsorted. Each move places the next smallest to the current position of the index by swapping.Selection Sort Algorithmint arr[5]= { 5,4,2,1,3 };int i, j ;Traverse from index i=0 to i
2K+ Views
We are given an integer number Num as input. The goal is to find the reverse of the number using stack.Stack:- A stack is a data structure in C++ which stores data in LIFO ( Last in First Out) manner. Major operations of stack are-:Declaration-: stack stck; //stck is now a stack variable.Finding Top using top(). Function stck.top() returns reference of top element in the stckRemoving Top using pop(). Function removes topmost element from the stckAdding element to top using push(). Function stck.push( value ) adds item value in stack. Value should be of type stck.Check if staxk is ... Read More
5K+ Views
To find the row sums if NA exists in the R data frame, we can use rowSums function and set the na.rm argument to TRUE and this argument will remove NA values before calculating the row sums.For Example, if we have a data frame called df that contains some NA values then we can find the row sums by using the below command −df$Row_Sums
13K+ Views
We are given an integer array Arr[] as input. The goal is to find maximum and minimum elements among the array using recursive methods.Since we are using recursion, we will traverse the whole array till we reach length=1 then return A[0] which forms the base case. Else compare current element with present minimum or maximum and update its value by recursion for later elements.Let us see various input output scenarios for this −Input − Arr= {12, 67, 99, 76, 32};Output − Maximum in the array :99Explanation − Out of all elements 99 is maximum among them.Input − Arr= {1, 0, -99, 9, 3};Output − Minimum ... Read More
2K+ Views
We are given a string containing a binary number. The goal is to find the equivalent decimal number using the recursive method.A binary number can be converted to decimal using following method-: Traverse from LSB to MSB and multiply each with power of 2i Where 0
584 Views
To add zero before a vector in R, we can simply use rep function and provide the number times we want to have zero in the vector.For Example, if we have a vector called X that contains three values say 1, 2, 3 and we want to add three zeros before this vector then we can use the command as given below −X
488 Views
Suppose we have a vector that contains only frequencies and we want to create a bar chart in base R using these frequencies with color of bars based on frequencies, therefore, we can use barplot function and providing the color of the bars with as shown in the below ExamplesThe function is as follows −heat.colors functionExample 1To fill the bars in a base R barplot with colours based on frequency, use the command given below −Frequency_1
995 Views
We can create a circle in R by using draw.circle function of plotrix package and default color of the circle is white. If we want to change the color of a circle then we can use col argument and pass the desired colors.For Example, if we want to create a blue colored circle then we can use the command given below −draw.circle(5, 5, 2, col="blue")Check out the below Example to understand how it works.ExampleTo create a circle filled with a colour, use the command given below −plot(1:10, type="n") OutputIf you execute the above command, it generates the following Output −To ... Read More