C++ program to check if a number is perfect or not

A perfect number is a number that is equal to the sum of its positive divisors excluding the number itself. For example, 28 is a perfect number because the sum of its divisors is 1 + 2 + 4 + 7 + 14 = 28 . Similarly, 6 is also a perfect number because 1 + 2 + 3 = 6.

Read

C++ program to check if a number is palindrome or not

A number is called a palindrome number if its reverse is equal to the number itself. For example, 121 is a palindrome number because it's reverse 121 is equal to the number.

Read

C++ program to find the first and the last occurrence of a character in a string

Let's find out the first and the last occurrence of a user given character in a string in C++. C++ provides two methods to do that easily, but I will also show you how to solve it by using a loop. The program will take the string and the character as input from the user, finds out the first and the last occurrence position and print these values. in a string

Read

C++ program to find the larger string

To find out the larger string, you need to find out its length. In C++, we can find out the length of a string using the strlen method. In this tutorial, we will learn how to find out the length of the string, and how to find the larger string in C++.

Read

Type assertion in typescript explanation with example

Type assertion in typescript is used to set the type of a variable and tell the compiler not to infer this. Suppose, you are switching from JavaScript to TypeScript and you know the type of one variable, you can tell the typescript compiler that this is the type this variable will have and you shouldn't do any more type checking for it. This is called "type assertion". Type assertion is used for compile-time checks. You can set type of one variable as number, string or any other type. For example :.

Read

Keywords in dart

Keywords are treated differently. Like other programming languages, keywords are words you can't use as identifiers. Actually, you can use a few keywords as identifiers but you shouldn't if you want to follow the best practices.

Read

Kotlin for loop explanation with examples

for loop in Kotlin is used to iterate through an iterator. You can iterate through array, map or anything that provides an iterator. In this tutorial, I will show you how to use a for loop in Kotlin with different examples. It's syntax is :.

Read

Check odd or even using 'when' in Kotlin

We can always find if a number is odd or even is to use one if-else block. This is the easiest process used in all programming languages. But in Kotlin, we can also use one when block. when block is more powerful. You can use it as a statement or as an expression. statement means it will work as an if-else statement and expression mean it will return value based on an input.

Read

C strspn function explanation with examples

strspn() function is defined in string.h header file. It is used to find out the total number of matched characters of a string in a substring. In this tutorial, I will show you how to use this method with one example program.

Read

C strrchr library function explanation with example

strrchr() function can be used to get the last substring in a string starting from a specific character. It returns one pointer of a substring. We can use this pointer to print the substring.

Read