473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to write for a loop?

24
printf("\nEnter the number of terms:\n");
scanf("%i",&j);
printf("\nPlease enter expression info as follow:\n");

{
double value;
double power;
double times;
int pos;
int isX;
int KnowX;


printf("-------- expression info:--------\n");
printf("What is the single value? =");
scanf("%f",&value);

printf("How many numbers of xtimes? =");
scanf("%f",&power);

printf("What is the power value? =");
scanf("%f",&times);

printf("What is the sign ? =");
scanf("%i\n",&pos);

}

with the above code how do i add the loop?Thank guys for the help
Oct 18 '06 #1
3 2312
sircool
12
printf("\nEnter the number of terms:\n");
scanf("%i",&j);
printf("\nPlease enter expression info as follow:\n");

{
double value;
double power;
double times;
int pos;
int isX;
int KnowX;

do
{
printf("-------- expression info:--------\n");
printf("What is the single value? =");
scanf("%f",&value);

printf("How many numbers of xtimes? =");
scanf("%f",&power);

printf("What is the power value? =");
scanf("%f",&times);

printf("What is the sign ? =");
scanf("%i\n",&pos);
function(); // that will be calculate the power
printf("if you want to calculate another one type 'e' otherwise program will close");

while(getche()=='e' );
}
return 0;
i add do while loop to your code
getche() function takes a character that will ask users request if user types e it loops again otherwise program will end...
i hope it was helpfull
Oct 18 '06 #2
cool17
24
thank for the help. But on the above of my code i ask user for the number of terms needed , i will den prodced the data as required... So is there any other ways of writting it?
Oct 19 '06 #3
for loops - general form


for( 'StartingCondition'; 'ConditionConstraint'; 'AdvanceCondition)
{

// Do stuff while ConditionConstraint is not met

}

Usually you write them in a form similar to below

int i;
for( i = startingvalue; i < maxvalue; i++)
{
cout << i << endl;
}

This states that I want to print all the integers from startingvale to maxvalue-1 because each time I run the loop, I increase i by 1 (i++).
Oct 19 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: .Net Sports | last post by:
I want to include some asp if statements inside a do until loop, predicated on the recordset going until EOF. I do not have any < % %> delimiters inside the include file. The below doesnt show the...
5
by: John Dumais | last post by:
Hello, I have been trying to figure out how to write an array of doubles (in this specific case) to a binary stream without using a loop. What I have been doing is... foreach(double d in...
9
by: John Salerno | last post by:
I assume this is the way for loops are written in C, but if it helps to be specific, I'm referring to C# for loops. The Python for loop seems to be the same (or similar) to C#'s foreach loop: ...
1
by: James | last post by:
vb.net 2003 - console program i've read a array of machines and i wishes to display on console the machines name on the *same line.* How do i do this ? This is what i want say i got a text...
10
by: Pierre Thibault | last post by:
Hello! I am currently trying to port a C++ code to python, and I think I am stuck because of the very different behavior of STL iterators vs python iterators. What I need to do is a simple...
4
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
1
by: showson1 | last post by:
Hi all! I have some files that are basically a TIF with an ASCII header. I wrote an app that reads in the file, pulls some values from the header and writes out everything after the header as a...
8
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
5
by: =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?= | last post by:
I'm sorry, but I've read your code a couple of times and just don't see where the Form1 is initialized. Form1 also sounds like a class name, and this would be how you could do some form operations...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.