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 2521 of 3366
210 Views
Input N which is equivalent to the number till where series should be printedInput : N=5 Output : 0 ¼ ½ ¾ 1AlgorithmSTART Step 1 -> declare start variables as int num , den, i, n Step 2 -> input number in n Step 3 -> Loop For from i to 0 and i End For Loop STOPExample#include int main(int argc, char const *argv[]) { int num, den; int i, n; printf("Enter series limit"); scanf("%d", &n); //Till where the series will be starting from zero for (i = 0; i < n; i++) { ... Read More
2K+ Views
Given two sorted arrays and output should display their uncommon elementsGiven : array1[]= {1, 4, 6, 9, 12} array2[]= {2, 4, 7, 8, 9, 10} Output : 1 2 6 7 8 10 12AlgorithmSTART Step 1 -> declare two arrays array1 and array2 with elements as int and variables n1, n2, i to 0 and j to 0 Step 2 -> calculate number of elements in array1 sizeof(array1)/sizeof(array1[0]) Step 3-> calculate number of elements in array2 sizeof(array2)/sizeof(array2[0]) Step 4 -> Loop While till i loop While i < n1 && array1[i]!=array2[j] Print array1[i++] Step 7 -> End Loop ... Read More
232 Views
It will display the missing values from the given set entered by the userGiven : array = {88, 105, 3, 2, 200, 0, 10}; Output : 1 4-9 11-87 89-99AlgorithmSTART STEP 1-> Take an array with elements, bool flag[MAX] to Fale, int i, j, n to size of array Step 2-> Loop For from I to 0 and i=0 Set flag[array[i]]=true End IF Step 3 -> End For Loop Step 4 -> Loop For from i to 0 and i=0) { flag[array[i]] = true; //Making the value of the elements present in ... Read More
256 Views
Input three strings and replace each string with a character which user has entered and then display edited strings. After that, concatenate edited strings and display them.Input: string 1 : tutorials replacement character for string 1 : x String 2 : points replacement character for string 2 : y String 3: best replacement character for string 3 : z Output : string 1: xxxxxxxxx String 2 :yyyyyy String 3 : zzzz After concatenation : xxxxxxxxxyyyyyyzzzzAlgorithmSTART Step 1-> declare three array of characters str1, str2 and str3 with variables as ch1, ch2 and ch3 ... Read More
330 Views
Input a string and find the total number of words, vowels and frequency of a character enter by a userInput : enter s string : I love my MOM Enter a charcter of which you want to find a frequency: M Total frequency of M : 2 Total number of vowels : 4 Total number of words : 4AlgorithmSTART Step 1 Declare array of string, ch, i, freq to 0, vow to 0, word to 0 Step 2 Input a string and a character ch Step 3 Loop for from i to 0 and str[i]!=’\o’ ... Read More
188 Views
Given with n numbers program must find those n number whose sum is a perfect squareInput : 5 Output : 1 3 5 7 9 1+3+5+7+9=25 i.e (5)^2AlgorithmSTART Step 1 : Declare a Macro for size let’s say of 5 and i to 1 Step 2: loop While till i printing (2*i)-1 Step Step 2.2 -> incrementing i with 1 Step Step3-> End loop While STOPExample#include # define SIZE 5 int main() { int i=1; while(i
9K+ Views
A JButton is a subclass of AbstractButton and it can be used for adding platform-independent buttons in a Java Swing application. A JButon can generate an ActionListener interface when the user clicking on a button, it can also generate the MouseListener and KeyListener interfaces. By default, we can create a JButton with a text and also can change the text of a JButton by input some text in the text field and click on the button, it will call the actionPerformed() method of ActionListener interface and set an updated text in a button by calling setText(textField.getText()) method of a JButton class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public ... Read More
1K+ Views
A JTextArea is a subclass of JTextComponent class and it is a multi-line text component to display the text or allow a user to enter the text. A JTextArea can generate a CaretListener interface when we are trying to implement the functionality of the JTextArea. By default, a JTextarea allows the orientation from left to right, if the user wants to enter a text from right to left by using the setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT) method of JTextArea class.Exampleimport java.awt.*; import javax.swing.event.*; import javax.swing.*; public class JTextAreaOrientationTest extends JFrame { private JTextArea textArea; public JTextAreaOrientationTest() { setTitle("JTextAreaOrientation Test"); textArea = new ... Read More
1K+ Views
A JTableHeader is a subclass of JComponent class, When we create a JTable object, the constructor creates a new JTableHeader object to manage the table component's header. A JTable supplies a setTableHeader() method that establishes the table header component's JTableHeader object and a getTableHeader() method that returns a reference to the table header component's JTableHeader object. We can set a tooltip text to each column of a JTableHeader by overriding the getToolTipText() method of JTableHeader class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class JTableHeaderToolTipTest extends JPanel { private DefaultTableModel dmodel; private JTable table; private JScrollPane jsp; public JTableHeaderToolTipTest() ... Read More
1K+ Views
In this section, we will see how we can get the sum of all odd prime factors of a number in an efficient way. There is a number say n = 1092, we have to get all factor of this. The prime factors of 1092 are 2, 2, 3, 7, 13. The sum of all odd factors is 3+7+13 = 23. To solve this problem, we have to follow this rule −When the number is divisible by 2, ignore that factor, and divide the number by 2 repeatedly.Now the number must be odd. Now starting from 3 to square root ... Read More