![How To Use While Loop In Dev C++ How To Use While Loop In Dev C++](/uploads/1/2/6/2/126216104/336921448.jpg)
How To Use While Loop In Dev C Download
![While While](/uploads/1/2/6/2/126216104/515761183.png)
I would like to be shown a bit about how to do while loops with increments
Hi there I have recently started using Dev c++ in my computer labs at school,
I know your not here to give the ansers to my work but i would
just like somebody to point me in the write direction
It took me a while to pick up the basics but I have more of a jist now.
But the while loops still baffle me!
In one of the sheets I have been given, part I;m stuck on asks:
write a while loop that will call a function that takes two numbers, one double and one int, and raises the first number to the power of second one and return the result. I have managed to do this part without the return the result? then
the next part is the part I really dont know what to do: the while loop needs to keep incrementing the int used in the function each time, this is meant to carry on untill the result of the function call exceeds 500?
the calculation part is also meant to be in a loop?
then an output line line needs to be included for each function call, to see the effect
please help, I am utterly stuck and have searched everywhere.
I was really starting to enjoy c ++ before i could majorly stuck for hours on end!
heres what i have managed to do so far
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
int read_int(char [],char []);
int int1;
double double1;
/*int result; I dont know how to use this, but just know it musthere.*/
int main(){
/* int1=1
/this is me trying to get a while loop running
while (int1<500)*/
double1=read_int('number1:','lf'); int1=read_int('number2:','%d');
printf('number1 to the power of number2 = %lf rn', pow(double1,int1));
/*return result;*/
system ('PAUSE');
return 0;
}
int read_int(char prompt[],char format[])
// subroutine to get undisclosed varying size of number//
{
char line[100];
int retvalue;
printf('%s',prompt);
fgets(line,sizeof(line),stdin);
line[strlen(line)-1]='0';
sscanf(line, '%d', &retvalue);
return retvalue;
}
Hi there I have recently started using Dev c++ in my computer labs at school,
I know your not here to give the ansers to my work but i would
just like somebody to point me in the write direction
It took me a while to pick up the basics but I have more of a jist now.
But the while loops still baffle me!
In one of the sheets I have been given, part I;m stuck on asks:
write a while loop that will call a function that takes two numbers, one double and one int, and raises the first number to the power of second one and return the result. I have managed to do this part without the return the result? then
the next part is the part I really dont know what to do: the while loop needs to keep incrementing the int used in the function each time, this is meant to carry on untill the result of the function call exceeds 500?
the calculation part is also meant to be in a loop?
then an output line line needs to be included for each function call, to see the effect
please help, I am utterly stuck and have searched everywhere.
I was really starting to enjoy c ++ before i could majorly stuck for hours on end!
heres what i have managed to do so far
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
int read_int(char [],char []);
int int1;
double double1;
/*int result; I dont know how to use this, but just know it musthere.*/
int main(){
/* int1=1
/this is me trying to get a while loop running
while (int1<500)*/
double1=read_int('number1:','lf'); int1=read_int('number2:','%d');
printf('number1 to the power of number2 = %lf rn', pow(double1,int1));
/*return result;*/
system ('PAUSE');
return 0;
}
int read_int(char prompt[],char format[])
// subroutine to get undisclosed varying size of number//
{
char line[100];
int retvalue;
printf('%s',prompt);
fgets(line,sizeof(line),stdin);
line[strlen(line)-1]='0';
sscanf(line, '%d', &retvalue);
return retvalue;
}
C++ Break From While Loop
Do-while loop in C with example. By Chaitanya Singh Filed Under: Learn C. As discussed in the last tutorial about while loop, a loop is used for repeating a block of statements until the given loop condition returns false. In this tutorial we will see do-while loop. Do-while loop is similar to while loop, however there is a difference. Mar 08, 2011 How to write a Loop Program. How to write a Loop Program. It's very similar to the while loop, except that this time the statements inside the loop will be executed at least once, in the case that the condition isn't met, unlike the other two, in which the loop will be skipped in a case like this. I use dev-C and so does my.