chevron_left

Recent posts tagged for-loop

19 0 2 min.
**A counter used in a For Loop cannot be initialized within the for loop statement. true or false?** ======================================================================== Hi, In this post we will get the answer of the question - "A counter used i...
posted Sep 7 sakshi 955 points
16 1 3 min.
In this article we will discuss all different types of loops and their usage in JavaScript. This is hopefully going to be very informative for those looking to use loops in JS but wondering which should they use or just want to learn about loops. If ...
posted Aug 31 ahsanhanif99 202 points
19 0 2 min.
Normally, you can iterate through all elements in an array, map, vector, … using the ordinary for-loop:#include <iostream> using namespace std; int main() { int arr[] = {1, 2, 3, 4, 5}; for(int i = 0; i < 5; i++) { cout &...
posted Aug 23 hhh98hd 226 points
4 0 3 min.
For loop provides a concise way of writing the loop structure. Unlike a while loop, a for statement consumes the initialization, condition and increment/decrement in one line thereby providing a shorter, easy to debug structure of looping.Syntax:for ...
posted Aug 22 Yogesh Sharma 337 points
3 1 2 min.
string is one of the basic data types in C++ and among the most widely used. Therefore, it is a good thing to learn new knowledge about string in C++. In this article, I am going to show how to get a char from a string in C++...
posted Aug 16 hhh98hd 226 points
14 0 2 min.
In this article, I would like to share about how to convert a string to an int array. So let’s begin !In reality, computers do not have any conceptions of alphabetic letters and they can only understand numbers.  Thus, there is a...
posted Aug 10 hhh98hd 226 points
8 0 2 min.
C+11 intrpduced vector, which can be seen as a replacement for primitive arrays. In this article, I am going to represent to you the way to add elements to a vector. So let’s begin !To declare a vector, you just need to follow the syntax b...
posted Aug 10 hhh98hd 226 points
7 0 2 min.
As you know, a number is called prime if it is only divisible by 1 and by itself. For example, they are 2, 3, 5, 7, 11, 13, 17, ... In this article, I will present to you the way to check if a number is prime or not. So let’s begin !G...
posted Aug 6 hhh98hd 226 points
5 0 2 min.
In programming languages, conversion from a number to a string and vice versa is a popular task. In this article, I will guide you how to convert an int variable intro a string variable in C++. So let’s begin !Method 1: Usin...
posted Aug 6 hhh98hd 226 points
5 0 2 min.
In C++ char arrays are widely used along with other data types like int, double, float, string, .... For most cases, the first thing to do when working with char arrays is to get their lengths. To help you when dealing with c...
posted Aug 3 hhh98hd 226 points
7 0 2 min.
In C language, char arrays are widely used in many applications and algorithms. For most cases, the first thing to do when working with char arrays is to get their lengths. To help you when dealing with char arrays, in t...
posted Aug 3 hhh98hd 226 points
8 0 2 min.
Programming exercises for IT students often involve count number of elements that satisfy some criterias. One of them is the problem that requires to count the number of vowels in a string. In this article, I will show you how to solve this proble. L...
posted Aug 2 hhh98hd 226 points
1 0 1 min.
In this post I will present the way to find the sum of n numbers usng for loop. Basically, we will use an array to store values and then use a variable to add values.First of all, we need get n - the amount of numbers and declare an array w...
posted Jul 31 hhh98hd 226 points
0 0 7 min.
Differenсe  between  Fоr  аnd  Fоreасh  in  JаvаThe  fоreасh  lоор  is  а  соntrоl  struсture  fоr  trаversing  items  in  аn  аrrаy  оr  а  соll...
posted Jul 1 sakshi 955 points
21 2 2 min.
​Саn  yоu  hаve  а  fоr  lоор  inside  а  while  lоор Yes,  We  саn  рut  а  fоr  lоор  inside  а  while  lоор  оr  а  dо-while  l...
posted Jun 16 sakshi 955 points
22 3 1 min.
Here we study about how to write a C++ program to find largest and smallest of n numbers.#include<iostream> using namespace std; int main () { int arr[10], n, i, max, min; cout << "Enter the size of the array : "; cin >...
posted Jun 11 Jeevani 120 points
27 1 1 min.
In this program, we need to find the duplicate characters in the string.To find the duplicate character from the string, we count the occurrence of each character in the string. If count is greater than 1, it implies that a character has a duplicate ...
posted Jun 10 Jeevani 120 points
0 2 1 min.
I will start by explaining how a for loop works. A for loop is one of the easiest loops to use, you usually use it when you already know for how long or how many times you want the loop to go through the codes that you have provided. A for loop is co...
posted May 2 Tegra Balonga 0 points
3 0 1 min.
The break statement is used for  iterrupting flow of a loop, i.e. for, while. These loops are mostly used for iterating the list of elements, array, lists, tuples. The reason to this issue is simple and it happens quite often.Syntax:   ...
posted Jan 24 IamAdinath 0 points
0 0 1 min.
In this article, I am going to explain how to assign values to an array in java by using for loop. One can use many techniques to assign values to arrays but I will be using Scanner class.ApproachIn the below program, I have declared a class Demo and...
posted Nov 4, 2020 MallikaShaik672 0 points