# Specific condition not working in my do-while loop?

int dbgEnter(int measurements[], int *nr) { int i = 0; do { printf("Enter Measurement #%d: ", i+1); scanf("%d", &measurements[i]); i++; int *nr = &i; } while (i < MAX && measurements[i] != 0); For some reason measurements[i] != 0 doesn’t seem to register as a condition for the while-loop. I tried it inside do with… Read More Specific condition not working in my do-while loop?

# Why is my do-while loop not producing the same results as my for & while loops?

I’m trying to write the same loop to calculate the sum of the integers from 1 to the input value, and output the sum 3 different ways, and so far I’ve completed my for and while loops correctly, and had them output the same result. However, for some reason my do-while loop isn’t working properly,… Read More Why is my do-while loop not producing the same results as my for & while loops?

# Trying to stop a Do-While Loop for an application

I’m creating an application for a homework, the problem is that I am trying to create a do-while loop to exit the application (Using the question "Do you want to exit (Y/N)"). To work with the do-while loop, I created a method to store the app and then called the method in the do-while loop,… Read More Trying to stop a Do-While Loop for an application

# C++: For two different functions with do-while loops, why does x+=y give the same result as x=x+y in one function but not the other?

For function A below, I get a different result when I use "est += XXX" as compared to using "est = est + XXX". The former gives a result of 1.33227e-15 while the latter gives an result of 8.88178e-16. On the other hand, for function B below, I get the same result regardless of whether… Read More C++: For two different functions with do-while loops, why does x+=y give the same result as x=x+y in one function but not the other?

# Do while loop keeps looping c++

So, I want this program to keep prompting when the number of digits isn’t 16, that part worked, but whenever I try to input 16 digits it loops without letting me type anything in again. This is what I wrote: do{ cout<<"insert number pls: "; cin>>number; //counting digits number_count = 0; while(number != 0){ number… Read More Do while loop keeps looping c++

# scanf inside an If statement on a do while loop messes up the inputs

When the input is a negative integer, the program should ask if you want to reset. It worked fine when I test it with a negative integer. But when I try a positive integer, it doesn’t work (I have to enter stuff twice). int main(void) { int user_input; char check; do { printf("Enter a positive… Read More scanf inside an If statement on a do while loop messes up the inputs

# How do I add a do-while loop in this program so that if the input is less than 4 it doesn't print anything

#include <stdio.h> int main () { int row, i, j; printf("Enter a number: "); scanf("%d", &row); for (i=1; i<=row; i++) { for (j=1; j<=row; j++) { if (i==1 || i==row || i+j==row+1) { printf("*"); } else { printf(" "); } } printf("\n"); } printf("\n\n"); } return 0; } The program prints out the letter "Z"… Read More How do I add a do-while loop in this program so that if the input is less than 4 it doesn't print anything

# Using a do while loop correctly?

My conditions are as follows : If the value of userIncome is entered more than 400000, show error. Similarly, if the value is less than 500, show error. Repeat the loop until a correct value is entered. #define _CRT_SECURE_NO_WARNINGS #define minINCOME 500.00 #define maxINCOME 400000.00 #include <stdio.h> int main(void) { float userIncome ; printf("+————————–+\n" "+… Read More Using a do while loop correctly?

# how to make loops from smallest to largest number?

a = int(input("first number: ")) b = int(input("second number: ")) for x in range (a,b): print(x, end = ‘ ‘) #I am making a program that would display a number from smallest to largest #for example: the first number is 10 then the second number is 1 : and my expected result is 1,2,3,4,5,6,7,8,9. the… Read More how to make loops from smallest to largest number?