Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 263 of 377

C++ Program to Convert Array to Set (Hashset)

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 6K+ Views

The array is a data structure that is available in C++ and is used to hold a sequential collection of elements of the same type. An array has a size that is fixed, but can be expanded or shrank if needed. It is important to think of an array as a collection of variables of the same type even though it is used to store a collection of data. Sets, or in this case unordered sets are a container that stores elements of a particular datatype in any order. A hash table is used to implement an unordered_set where keys ...

Read More

C++ Program to convert primitive types to objects

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 1K+ Views

Primitive datatypes in C++ are datatypes that are predefined in the language itself; like int, float, double, etc. Objects are instances of a class, and C++ being an object-oriented language, conversion between primitive data types and objects is necessary. A class serves as a data type's architectural plan. Although this doesn't describe any data specifically, it does specify what the class name signifies, i.e., what an object of the class will look like and what operations may be carried out on it. Conversion between a primitive data type to an object is not defined explicitly in the C++ language compilers, ...

Read More

C++ Program to convert double type Variables into int

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 3K+ Views

In C++, variables of the int type can only hold positive or negative integer values; they cannot hold fractional values. There are float and double values available for this purpose. In order to store fractional numbers with up to seven digits after the decimal point, double datatype was created. Integer to double datatype conversion can either be done automatically by the compiler (known as "implicit" conversion) or explicitly requested by the programmer to the compiler (known as "explicit" conversion). In the sections that follow, we go over the various conversion methods. Implicit Conversion The compiler does implicit type conversions automatically. ...

Read More

C++ Program to convert int Variables into double

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 13K+ Views

Int type variables in C++ are used to contain positive or negarive integer values, but this type is unable to contain fractional values. For that, there are float and double values. Double datatype is specifically designed to hold fractional values upto seven digits after the decimal point. Conversion between integer and double variables can be automatically handled by the compiler, known as ‘implicit’ conversion or can be explicitly triggered by the programmer to the compiler. We discuss the different ways of conversion in the following sections. Implicit Conversion Implicit type conversions are done automatically by the compiler. For this to ...

Read More

C++ Program to Convert int Type Variables into String

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 847 Views

Integer type variables in C++ are able to store positive or negative integer values upto a predefined range. String variables can store a sequence of alphabets, numerals, and special characters. There are many use cases where the conversion from int to string is needed. We discuss 3 different methods to convert an integer variable into a string. If we discuss the algorithm, it is pretty straightforward. We take input in an integer variable and then convert it into a string variable. Using to_string function The easiest way in C++ to convert an integer value to a string is using the ...

Read More

C++ Program to convert Boolean Variables into String

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 4K+ Views

Boolean variables in C++ can contain only two distinct values, ‘true’ or ‘false’. If we translate these values to string, ‘true’ will be mapped to ‘1’ and ‘false’ will be mapped to ‘0’. Boolean values are mainly used to check if a condition in a program has been met or not. There aren’t direct conversions from Boolean to string like we have seen in conversions from int to long and float to double. But there are needs to translate a Boolean value to string, and we explore different ways to convert a binary Boolean value to a string value. Using ...

Read More

C++ Program to Convert int Type Variables to long

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 10K+ Views

C++ is a statically typed language, and because of that all of its variables require the datatype to be declared beforehand. The datatypes are used to represent which type of value is contained inside a variable. In C++, the variables to contain numerical values are int, long, float, and double. int and long are used to represent integer values, whereas float and double are used to represent fractional values. Both int and long contains integer values with one difference which is, int is of size 4 bytes and long is of size 8 bytes. Conversion of int to long can ...

Read More

C++ Program to Check if a String is Numeric

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 12K+ Views

It can be quite helpful to use strings or characters while tackling logical programming difficulties. Characters in strings are 1-byte data types that can store symbols from ASCII values. Strings are collections of characters. The symbols could be special characters, numerals from the numeric system, or letters from the English alphabet. This article will teach you how to use C++ to determine whether a character is a numeric character or not. Checking string is numeric or not To check whether the given string is numeric or not, we need to check each character in it is a digit or not. ...

Read More

C++ Program to Check Whether a Character is Alphabet or Not

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 4K+ Views

Using strings or characters is sometimes very useful while solving some logical programming problems. Strings are a collection of characters and characters are 1-byte datatype to hold symbols from ASCII values. The symbols can be letters from English alphabets, numeric digits, or special characters. In this article, we shall learn how to check whether a character is a letter in English an alphabet or not using C++. Checking isalpha() function To check whether a number is an alphabet or not, we can use the isalpha() function from the ctype.h header file. This takes a character as input and returns true ...

Read More

C++ Program to Check Whether a Number is Positive or Negative

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 5K+ Views

In modern programming languages we work with signed numbers and unsigned numbers also. For signed numbers the numbers can be positive or negative or zero. To represent negative numbers, the systems store the numbers in 2’s complement method. In this article we shall discuss how to determine a given number is positive, or negative in C++. Checking using if-else conditions The basic sign checking can be done by using if else conditions. The syntax for the if-else conditions is like below − Syntax if { perform action when condition is true } else { ...

Read More
Showing 2621–2630 of 3,768 articles
« Prev 1 261 262 263 264 265 377 Next »
Advertisements