
-----------------------------------
sbuhari
Wed Jul 27, 2011 12:28 pm

Need help in For loops and while loops
-----------------------------------
OK here is the thing I have a while loop and I want to know how I can count the number of times the loop has occured. 

here is my code:

 while(CusId){
                        printf("Please Enter Your Customer ID Number Or 0 To Exit: ");
                        scanf("%d",&CusId);
                        if(CusId==0){
                        }
                        else{
                        printf("Please Enter Your Current Balance: ");
                        scanf("%d", &CurBal);
                        printf("Your New Charges: ");
                        scanf("%d", &NewChar);
                        printf("The Available Credit: ");
                        scanf("%d", &AvaCred);
                        printf("The Credit Limit: ");
                        scanf("%d", &CreLim);
                        }
                }

please help me

-----------------------------------
apython1992
Wed Jul 27, 2011 1:51 pm

RE:Need help in For loops and while loops
-----------------------------------
Do you know how to:
- Declare a variable and initialize it?
- Increment an integer?

:)

-----------------------------------
sbuhari
Wed Jul 27, 2011 2:40 pm

Re: Need help in For loops and while loops
-----------------------------------
yes I do incrementing involves for loops

-----------------------------------
Insectoid
Wed Jul 27, 2011 4:17 pm

RE:Need help in For loops and while loops
-----------------------------------
Well, all you really need to do is make an int initialized to zero, and inside the while loop add 1.


//the following loops function exactly the same
int i;
for (i = 0; i < 10; i++);

i = 0;
while (i