Use function as for loop control variable : For « Language Basics « C / ANSI-C

C / ANSI-C
1. assert.h
2. Console
3. ctype.h
4. Data Structure Algorithm
5. Data Type
6. Development
7. File
8. Function
9. Language Basics
10. Macro Preprocessor
11. Math
12. math.h
13. Memory
14. Pointer
15. setjmp.h
16. signal.h
17. Small Application
18. stdio.h
19. stdlib.h
20. String
21. string.h
22. Structure
23. time.h
24. wctype.h
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C / ANSI-C » Language Basics » ForScreenshots 
Use function as for loop control variable


#include <stdio.h>

int sqrnum(int num);
int readnum(void);
int prompt(void);

int main(void)
{
  int t;

  for(prompt(); t=readnum(); prompt())
    sqrnum(t);

  return 0;


int prompt(void
{
  printf("Enter a number: ");
  return 0;


int readnum(void)
{
  int t;

  scanf("%d", &t);
  return t;
}

int sqrnum(int num)
{
  printf("%d\n", num*num);
  return num*num;
}

  

           
       
Related examples in the same category
1. For statement: backwards
2. For : no first part
3. For: no init and loop backwards
4. Nested forNested for
5. For loop: List ten integersFor loop: List ten integers
6. For loop: Draw a boxFor loop: Draw a box
7. Use int as the while loop controller
8. Simplest for loop: user control the loop
9. Use for loop as the user selection's controller
10. Demonstrate multiple loop control variablesDemonstrate multiple loop control variables
11. For loop without first part
12. For loop without the third part
13. See the for loop terminating condition
14. For loop condition: loop will not execute
15. For loop: bigger increase
16. Prime number tester
17. nested for Demo
18. Use integer as the for loop controller
19. Set the init value for a for loop
20. More calculation in the for statement
21. Simplest for loop
22. Reverse order of for loop
23. Two condition for ending a for loop
24. Three level nested for loop
25. A simple for loopA simple for loop
26. More complex for loop: more statements
27. Infinite for loop with break
28. For loop with init value, stop condition and incr
29. Use char as int in a for loop
30. Nested for loop demo
w___w__w___.j___av_a___2__s___._co_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.