GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Nov-2007, 23:40
krystyna93 krystyna93 is offline
New Member
 
Join Date: Nov 2007
Posts: 6
krystyna93 is an unknown quantity at this point

Flowchart for a while loop;need help..


Hello there fellow programmers,

i have a bit of problem trying to create a flowchart for this pseudo code below...

could anyone help me out?

--------

Enrolment
TotalStudents = 0
CLASS_MAX = 25
WHILE TotalStudents <=CLASS_MAX
INPUT StudentName
INPUT StudentPhone
WRITE StudentName
WRITE StudentPhone
TotalStudents = TotalStudents + 1
ENDWHILE
DISPLAY ClassFullMsg
END

----------

your help will be much appreciated

thanks Krystyna
  #2  
Old 03-Nov-2007, 11:59
Kimmo Kimmo is offline
Regular Member
 
Join Date: Mar 2007
Location: Finland
Posts: 450
Kimmo is a jewel in the roughKimmo is a jewel in the roughKimmo is a jewel in the rough

Re: Flowchart for a while loop;need help..


So what's the problem?
  #3  
Old 04-Nov-2007, 21:21
Howard_L Howard_L is offline
Senior Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 1,007
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Flowchart for a while loop;need help..


I hadn't taken the time to try making a flowchat before so I gave it a try.
What a timesaver... I guess it would help in illustrating a project to a "team" though.
I don't know how right or wrong this might be, but have a laugh on me:
CPP / C++ / C Code:
/*  flowchart1.c    Some examples:  
[url]http://www.nos.org/htm/basic2.htm[/url]
[url]http://www.gidforums.com/t-16139.html[/url]
Enrollment
TotalStudents = 0
CLASS_MAX = 25
WHILE TotalStudents <=CLASS_MAX
INPUT StudentName
INPUT StudentPhone
WRITE StudentName
WRITE StudentPhone
TotalStudents = TotalStudents + 1
ENDWHILE
DISPLAY ClassFullMsg
END
____________________________________________________________________________
                                                                            |
       o---------o                                                          |
      (   start   )                                                         |
       o---------o                                                          |
            |                                                               |
o--------------------------------o                                          |
|   ** COMPILER DIRECTIVES **    |                                          |
| #include <stdio.h>             |                                          |
| #include <string.h>            |                                          |
o--------------------------------o                                          |
            |                                                               |
o--------------------------------------------o                              |
|   ** DECLARE DATA **                       |                              |
| int  i, j, quit, TotalStudents, CLASS_MAX; |                              |
| char c, class_list[25][2][20] = {{{0}}};   |                              |
o--------------------------------------------o                              |
            |                                                               |
o---------------------------------------o                                   |
|   ** ASSIGN STARTING VALUES **        |                                   |
| i=j=quit=TotalStudents=CLASS_MAX = 0; |                                   |
o---------------------------------------o                                   |
                   |                                                        |
    o---------------------------------------------------------------------o |
   /   ** GIVE INTRO AND USER INSTRUCTION **                             /  |
  / printf("Hi! And Welcome to the Uniblab Privacy Busting System \n"); /   |
 /  printf("Enter students' names followed by phone # : \n");          /    |
o---------------------------------------------------------------------o     |
                   |                                                        |
       o----------/ \-----------------------o                               |
      /    ** BEGIN LOOP **                  \                              |
v--<-<   while( c != 'q' || i < CLASS_MAX )   >--<--------------------<     |
|     \                                      /                        |     |
|      o----------\ /-----------------------o                         |     |
|<-FALSE           |<-TRUE                                            |     |
|     o-----------------------------------------o                     |     |
|    /   ** GET USER INPUT: NAME **            /                      |     |
|   /  fgets(class_list[i][j], 20, stdin);    /                       |     |
|  o-----------------------------------------o                              |
v                  |                                                  ^     |
|  o---------------------------------------------------------o        |     |
|  |   ** REMOVE \n FROM END OF fgets() STRING & INCREMENT   |        |     |
|  | class_list[i][j][ ( strlen(class_list[i][j]) )-1 ] = 0; |        |     |
|  | j++;                                                    |        |     |
|  o---------------------------------------------------------o        |     |
|                  |                                                  |     |
|     o-----------------------------------------o                     |     |
|    /   ** GET USER INPUT: PHONE #            /                            |
|   /    fgets(class_list[i][j], 20, stdin);  /                       ^     |
|  o-----------------------------------------o                        |     |
v                  |                                                  |     |
|  o---------------------------------------------------------o        |     |
|  |   ** REMOVE \n FROM END OF fgets() STRING               |        |     |
|  | class_list[i][j][ ( strlen(class_list[i][j]) )-1 ] = 0; |        |     |
|  o---------------------------------------------------------o              |
|                  |                                                  ^     |
|     o-------------------------------------o                         |     |
|     |   ** SET FOR NEXT LOOP **           |                         |     |
v     | i++;                                |                         |     |
|     | j = 0;                              |                         |     |
|     | TotalStudents++;                    |                         |     |
|     o-------------------------------------o                         |     |
|                  |                                                        |
|      o-----------------------------------------------------------o  ^     |
v     /   ** GET USER CHOICE TO TERMINATE **                      /   |     |
|    /  printf("\"q\" to quit or ENTER to continue entries:");   /    |     |
|   /   c = getchar();                                          /     |     |
|  o-----------------------------------------------------------o      |     |
|                  |                                                  |     |
|                  >------------------------>-------------------------^     |
|                                                                           |
>--------->--------v                                                        |
                   |                                                        |
     o------------/ \---------------------o                                 |
    /   ** BEGIN REPORT PRINTING LOOP **   \                                |
v--<    for(i=0; i < TotalStudents; i++);   >--<-----------------------<    |
|   \                                      /                           |    |
|    o------------\ /---------------------o                            |    |
|<-FALSE           |<-TRUE                                             |    |
|             o-----------o                                                 |
|             |  j = 0;   |                                            ^    |
|             o-----------o                                            |    |
|                  |                                                   |    |
|     o-----------------------------------------------------------o    |    |
v    /   ** PRINT NAME PART OF ONE LINE OF REPORT **             /     |    |
|   /   printf("%20s  ", class_list[i][j]);                     /      |    |
|  o-----------------------------------------------------------o       |    |
|                  |                                                   |    |
|             o-----------o                                                 |
|             |   J++;    |                                            ^    |
|             o-----------o                                            |    |
|                  |                                                   |    |
|     o-----------------------------------------------------------o    |    |
|    /   ** PRINT NUMBER PART OF ONE LINE OF REPORT **           /     |    |
v   /   printf("%15s \n", class_list[i][j]);                    /      |    |
|  o-----------------------------------------------------------o       |    |
|                  |                                                        |
|                  >------------------>--------------------------------^    |
|                                                                           |
>------------------v                                                        |
                   |                                                        |
            o--------------o                                                |
           (      END       )                                               |
            o--------------o                                                |
*/

#include <stdio.h>
#include <string.h>

int main(void)
{
  int  i, j, quit, TotalStudents, CLASS_MAX;
  char c, class_list[25][2][20] = {{{0}}};

  i=j=quit=TotalStudents=CLASS_MAX = 0;

  printf("Hi! And Welcome to the Uniblab Privacy Busting System \n");
  printf("Enter students' names followed by phone # : \n");
  while( c != 'q' || i < CLASS_MAX )
  {
    fgets(class_list[i][j], 20, stdin);
    class_list[i][j][ ( strlen(class_list[i][j]) )-1 ] = 0;
    j++;
    fgets(class_list[i][j], 20, stdin);
    class_list[i][j][ ( strlen(class_list[i][j]) )-1 ] = 0;
    i++;
    j = 0;
    TotalStudents++;
    printf("\"q\" to quit or ENTER to continue entries:");
    c = getchar();
  }
  for(i=0; i < TotalStudents; i++)
  {
    j = 0;
    printf("%20s  ", class_list[i][j]);
    j++;
    printf("%15s \n", class_list[i][j]);
  }
  return 0;
}
Howard;
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flowchart Problem ashayah C Programming Language 1 15-Oct-2007 14:28

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:19.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.