Saturday, May 22, 2010

C Program please help?

can anyone help me with c program?


i've to make a program using





int


+


%26gt;


while








i've got no idea what are all these things?!!

C Program please help?
Well, first you need a basic understanding of what those are.





int is a variable declaration. for example, you use it to tell the compiler that you want to make a new "number" variable.





int a = 0;





now, for the plus sign, thats an operator. You use it to either add two variables together or add a number to another variable. for example:





a += 1;





Means add one to a.





the greater than sign is used to compare two values, and you generally put this inside of the while statement which means repeat THIS code (Whatever is inside of the brackets) until the expression you pass becomes true.





for example:





while(a %26gt; i){


printf("hello there!");


}





I'm not going to do your program for you but I hope this helps you get on the right track.





Regards!


-Mr. Bob
Reply:int: this declares a variable for storing an integer...


example: int count; -or- int answers = 1; (to set an initial value)





+: this adds stuff to other stuff


example: count = count + 1;





++: this increments an integer variable by 1


example: count++; (does the same thing as the previous example)





while: this will repeat the code in it's {} block while the conditions in it's () is true


example: while(true){ // do something here //} (this example will run forever)





So here's a quick program using those elements...





int iq = 65;


while(100%26gt;iq){


iq++;


}

rose

No comments:

Post a Comment