Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + … + upto n terms in C++

Ravi Ranjan
Updated on 15-Jul-2025 18:29:51

1K+ Views

In this article, we are given an integer n. It defines the number of terms in the series: 1/1 + ( (1+2)/(1*2) ) + ( (1+2+3)/(1*2*3) ) + … + up to n terms. Our task is to write a program to calculate the sum of series 1/1 + (1+2)/(1*2) + (1+2+3)/(1*2*3) + … up to n terms. The above series can be represented as: $$ \sum_{k=1}^{n} \frac{\sum_{j=1}^{k} j}{k!} $$ Scenario The following example calculates the sum for the given series up to 4 terms: Input: n ... Read More

Angle Between Hands of a Clock in C++

Ravi Ranjan
Updated on 15-Jul-2025 18:27:16

2K+ Views

In this article, we have values of hours and minutes respectively. Our task is to find a smaller angle formed between the hour and the minute hand. The formula for calculating the angle between them is: angle = |30*h - 5.5min|. Here are some examples given below: Scenario 1 Input: Time = 12:45 Output: 112.5 Explanation: Here, hour = 12, minute = 45 angle = |30*h - 5.5min| = |30*12 - 5.5*45| = |360 - 247| = 112.5 Scenario 2 Input: Time = 10:30 Output: 135 Explanation: Here, hour = 10, minute = 30 ... Read More

C++ Program to Implement Trie

Farhan Muhamed
Updated on 15-Jul-2025 18:04:38

2K+ Views

A Trie, also known as a prefix tree, is used to store and search for large sets of strings. In this section we will discuss all about Trie data structure, its operations, and how to implement it in C++. Trie Data Structure A Trie is a data structure similar to a tree that is used to store a dynamic set of strings. The root node represents an empty string, and each edge represents a character. The path from the root to a node represents a prefix of a string stored in the Trie. The image below show how a ... Read More

How to check multiple regex patterns against an input? Using Java.

Maruthi Krishna
Updated on 15-Jul-2025 17:58:40

5K+ Views

In Java, the strings that are used to find the pattern are known as regular expressions. In this article, we will learn to check multiple regex patterns against an input, and it can be done by using 2 approaches. Using Metacharacter Using the List object Using Metacharacter The meta character "|" in Java regular expressions allows you to match more than one regular expression. For example, if you need to match a particular input text with more than one expression, you need to separate them using the following: exp1|exp2|exp3 Example ... Read More

Count the number of columns in a MySQL table with Java

Alshifa Hasnain
Updated on 15-Jul-2025 17:58:08

430 Views

In this article, we will learn how to count the number of columns in a MySQL table using JDBC. We will be using the ResultSetMetaData to get details of the table by using simple examples. What is ResultSetMetaData? The ResultSetMetaData is an interface that is present in the java.sql package. Using ResultSetMetaData, we can get information about the table, for example, what are the column names of each and every table, and how many columns are there?. To create the object for ResultSet: ResultSet rs=st.executeQuery("Select * from Student"); The executeQuery method writes the records, which are then stored in the ... Read More

Add a value to Pair Tuple in Java

Alshifa Hasnain
Updated on 15-Jul-2025 17:57:26

1K+ Views

By default, Java does not have built-in tuple support; to use the tuple, we use the third-party library called Javatuples. Using this library, you can create a tuple of different sizes, starting from a single-element tuple, which is the Unit class, up to a ten-element tuple (Decade class). The following is the list of JavaTuples library classes: Unit: 1 element tuple Pair: 2 element tuple Triplet: 3 element tuple Quartet: 4 element tuple Quintet: 5 element tuple ... Read More

How to write a short literal in C++?

Akansha Kumari
Updated on 15-Jul-2025 17:35:04

993 Views

In the following article, we will learn about short literals in C++. In both C and C++, different data types have different literals. A literal is a fixed constant value, which is assigned to the variables of different data types. For example, here is a list of different data types with their literals. Datatypes Literals ... Read More

What are local variables in C++?

Akansha Kumari
Updated on 15-Jul-2025 17:31:11

525 Views

The variables, which are declared inside a function, block or method are known as local variables in C++. Their scope is limited to that function or block and can be accessed and used only within the area or scope they are defined. You cannot access or use them outside their scope. This is mainly used to prevent conflicts with other variables in other parts of the program and to efficiently manage memory. Key Characteristics of Local Variables Scope Limited : These variables are declared inside block or scope (usually {}) and are only visible and used ... Read More

How to write the first C++ program?

Akansha Kumari
Updated on 15-Jul-2025 17:30:42

18K+ Views

C++ is a high level programming language that is used to develop applications, work with operating systems, and much more. It is an extension of the C language, which combines both procedural programming (available in C) and object oriented programming. In this article, we will learn step by step the procedure of writing our first C++ program. Prerequist For this, make sure that your computer consists of the following two. C++ Compiler Text Editor or IDE Get a C++ Compiler It is a system that translates the source code (written ... Read More

C++ Programming Language Features

Akansha Kumari
Updated on 15-Jul-2025 17:29:49

831 Views

C++, also said to be a middle-level language, as it is a combination of both high-level features like abstraction with low-level language features like memory manipulation capabilities of assembly. It is a superset of C, as it compromises both C with object-oriented, therefore any valid C program will also be valid to C++ program.Top Features of C++ Programming Language C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. In this following article we will discuss some of the features of C++ that make it stand out among other programming languages: 1. ... Read More

Advertisements