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 15-Oct-2007, 10:39
ashayah ashayah is offline
New Member
 
Join Date: Oct 2007
Posts: 12
ashayah is an unknown quantity at this point
Question

Flowchart Problem


..i have a problem concerning flowchart.. i dont know how to make a flowchart on this code....

CPP / C++ / C Code:
#include <conio.h>
#include <stdio.h>

#define one       gotoxy(3, 11); textattr(BLACK<<4|WHITE); cprintf(" 1 ");
#define two       gotoxy(7, 11); textattr(BLACK<<4|WHITE); cprintf(" 2 ");
#define three     gotoxy(11,11); textattr(BLACK<<4|WHITE); cprintf(" 3 ");
#define four      gotoxy(3,  9); textattr(BLACK<<4|WHITE); cprintf(" 4 ");
#define five      gotoxy(7,  9); textattr(BLACK<<4|WHITE); cprintf(" 5 ");
#define six       gotoxy(11, 9); textattr(BLACK<<4|WHITE); cprintf(" 6 ");
#define seven     gotoxy(3,  7); textattr(BLACK<<4|WHITE); cprintf(" 7 ");
#define eight     gotoxy(7,  7); textattr(BLACK<<4|WHITE); cprintf(" 8 ");
#define nine      gotoxy(11, 7); textattr(BLACK<<4|WHITE); cprintf(" 9 ");
#define zero      gotoxy(15,11); textattr(BLACK<<4|WHITE); cprintf(" 0 ");
#define plus      gotoxy(15, 5); textattr(BLACK<<4|WHITE); cprintf(" + ");
#define minus     gotoxy(11, 5); textattr(BLACK<<4|WHITE); cprintf(" - ");
#define divide    gotoxy(3,  5); textattr(BLACK<<4|WHITE); cprintf(" / ");
#define multiply  gotoxy(7,  5); textattr(BLACK<<4|WHITE); cprintf(" * ");
#define ENTER     gotoxy(15, 9); textattr(BLACK<<4|WHITE); cprintf(" Enter ");
#define C         gotoxy(18, 7); textattr(BLACK<<4|WHITE); cprintf("C");
#define SHOW_     printf("   ");

void calcuForm (void);
void printSol1 (double value);
void printSol2 (double solution);
void printSol3(double b);
void entranceFace (void);

void calcuForm (void)
{
	gotoxy(22,2); textattr(BLINK|YELLOW<<4|BLACK); cprintf("SIMPLE ARITHMETIC CALCULATOR PROGRAM");

	gotoxy(1, 4);  printf("ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵");
	gotoxy(1, 5);  printf("³³ / ³ * ³ - ³ + ³   ³³");
	gotoxy(1, 6);  printf("³ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÁÄÄÄ´³");
	gotoxy(1, 7);  printf("³³ 7 ³ 8 ³ 9 ³   C   ³³");
	gotoxy(1, 8);  printf("³ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÄÄÄÄ´³");
	gotoxy(1, 9);  printf("³³ 4 ³ 5 ³ 6 ³ Enter ³³");
	gotoxy(1, 10); printf("³ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÄÄÄÄ´³");
	gotoxy(1, 11); printf("³³ 1 ³ 2 ³ 3 ³ 0 ³---³³");
	gotoxy(1, 12); printf("ÀÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÙ");
	gotoxy(1, 13); printf("³                     ³");
	gotoxy(1, 14); printf("ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵");

	gotoxy(25, 20); textattr(BLINK| BLACK<<4| WHITE); cprintf("Press the ESC key to exit...");
	return;
}

void main()
{
	double value = 0;
	double solution = 0;
	char symbol = '';
	int operate_a = 0, negative = 0;
	int x = 0;
	int y = 0;
	enum operate
	{enone, edivide,eplus, emultiply, enegative, eminus};
	int erase[10] = {0};
	clrscr();

	for(;;)
	{
	for(x=0; x<=10; x++)
	{
	if(x==1){solution = 0;}
	textbackground(3);
	textcolor(1);
	clrscr();


	if(x==10 && symbol != '\x1B' && symbol != '+' && symbol != '-'
	 && symbol != '*' && symbol != '/' && symbol != '\r' && symbol != '\x08'){ x--;

	
	 symbol = '\x0';
	 }

	switch(symbol)
	{
		case '1':    one;      if(x==1 && negative != enegative)
					  {solution += 1; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-1); erase[x] = 1;}
					  else { solution = ((solution*10)+1);
					  erase[x] = 1;}
				       break;
		case '2':    two;      if(x==1 && negative != enegative)
                			  {solution += 2; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-2); erase[x] = 2;}
                                          else { solution = ((solution*10)+2);
					  erase[x] = 2;}
				       break;
		case '3':    three;    if(x==1 && negative != enegative)
                		 	  {solution += 3; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-3); erase[x] = 3;}
					  else { solution = ((solution*10)+3);
					  erase[x] = 3;}
				       break;
		case '4':    four;     if(x==1 && negative != enegative)
                			  {solution += 4; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-4); erase[x] = 4;}
					  else { solution = ((solution*10)+4);
					  erase[x] = 4;}
				       break;
		case '5':   five;     if(x==1 && negative != enegative)
                			  {solution += 5; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-5); erase[x] = 5;}
					  else { solution = ((solution*10)+5);
					  erase[x] = 5;}
				       break;
		case '6':    six;      if(x==1 && negative != enegative)
                			  {solution += 6; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-6); erase[x] = 6;}
					  else { solution = ((solution*10)+6);
					  erase[x] = 6;}
				       break;
		case '7':    seven;    if(x==1 && negative != enegative)
                			  {solution += 7; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-7); erase[x] = 7;}
					  else { solution = ((solution*10)+7);
					  erase[x] = 7;}
				       break;
		case '8':    eight;    if(x==1 && negative != enegative)
                			  {solution += 8; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-8); erase[x] = 8;}
					  else { solution = ((solution*10)+8);
					  erase[x] = 8;}
				       break;
		case '9':    nine;     if(x==1 && negative != enegative)
                			  {solution += 9; erase[x] = solution;}
					  else if(x==1 && negative == enegative)
					  {solution = (-9); erase[x] = 9;}
					  else { solution = ((solution*10)+9);
					  erase[x] = 9;}
				       break;
		case '0':    zero;     if(x==1 && negative != enegative)
					{solution = 0;}
					  else if(x==1 && negative == enegative)
					  {solution = 0; erase[x] = 0;}
					  else { solution = ((solution*10));
					  erase[x] = 0;}
				       break;

		case '+':    plus;	if(x!=1){value = solution;}
					operate_a = eplus;
					x = 0; negative = enone;
					for(y=0;y<=10;y++)
					{
					erase[y]=0;
					}
					break;
		case '-':    minus;     if(x!=1){value = solution; negative = enone;}
					if(value){negative = enegative;}
					operate_a = eminus;
					x = 0; negative = enone;
					for(y=0;y<=10;y++)
					{
					erase[y]=0;
					}
					break;
                case '*':    multiply;  if(x!=1){value = solution;}
					operate_a = emultiply;
					x = 0; negative = enone;
					for(y=0;y<=10;y++)
					{
					erase[y]=0;
					}
					break;

		case '/':    divide;    if(x!=1){value = solution;}
					operate_a = edivide;
					x = 0; negative = enone;
					for(y=0;y<=10;y++)
					{
					erase[y]=0;
					}
					break;
		case '\x08': C; x--;
					if(x==1 && solution!=0){solution = (solution - erase[x]);}
					else if(solution!=0){solution = ((solution - erase[x])/10); }
					x--;
		}

	{

	if(symbol == '\x1B'){break;}

	calcuForm();
	if(symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/')
	{printSol1(value); x=0;
	}
	else if(symbol != '\r' && negative != enegative)
	{
		printSol2(solution);
	}
	else if(symbol != '\r' && negative == enegative)
	{
		printSol3(solution);
	}
	else if(symbol == '\r' && operate_a == eplus)
	{
		value += solution; x = 0; ENTER;
		printSol1(value); operate_a = enone;
                for(y=0;y<=19;y++)
		{
			erase[y]=0;
		}
	}
	else if(symbol == '\r' && operate_a == eminus)
	{
		value -= solution; x = 0; ENTER;
		printSol1(value); operate_a = enone;
		for(y=0;y<=10;y++)
		{
			erase[y]=0;
		}
	}
	else if(symbol == '\r' && operate_a == edivide)
	{
		if(solution != 0)
		{
			value /= solution; printSol1(value);
		}
		x = 0; ENTER;
		operate_a = enone;
		for(y=0;y<=10;y++)
		{
			erase[y]=0;
		}
	}
	else if(symbol == '\r' && operate_a == emultiply)
	{
		value *= solution; x = 0;  ENTER;
		printSol1(value); operate_a = enone;
                for(y=0;y<=19;y++)
		{
			erase[y]=0;
		}
	}
	else {ENTER; printSol2(solution); }
	}

	{
	switch(symbol)
	{
	 default:  SHOW_;
	}
	}

	symbol = '\x0';
	symbol = getch();
	}
	if (symbol == '\x1B'){break;}
	}
}
void printSol1 (double value)
{
	gotoxy(2, 13); printf("%18.2f", value);
	return;
}

void printSol2 (double solution)
{
	gotoxy(2, 13); printf("%18.2f", solution);
	return;
}

void printSol3 (double solution)
{
	gotoxy(2, 13); printf("%18.2f", -solution);
	return;
}



........can anyone would like to help me?!..what will i do?..thank yoU!..i wait for replies!..its due will be on wednesday! and i like to have it tomorrow for me to finalise it!:cry:
Last edited by LuciWiz : 16-Oct-2007 at 14:11. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 15-Oct-2007, 15:28
seprich seprich is offline
Member
 
Join Date: Jun 2007
Posts: 110
seprich has a spectacular aura aboutseprich has a spectacular aura about

Re: Flowchart Problem


Please use code tags [c] and [/c] when posting c code.

Other than that:
  • I assume you have at least seen some flowchart sometime, right? Anyway you could perhaps benefit from looking it up at good old wikipedia: http://en.wikipedia.org/wiki/Flowchart
  • Next thing: How much you understand about c programs? Making flowchart from a procedural program is quite straightforward. The program starts execution from the beginning of the main() function. So you follow there.
  • But perhaps most importantly: What did your lecturer/instructor instruct you to do? It doesn't seem likely that you were expected to transform the whole program line-by-line into flowchart. However you should have the best knowledge about what is expected.
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

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
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 13:31
Runtime Problem involving "printf" in C Program supamakia C Programming Language 2 09-Oct-2005 11:09
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 08:03
String problem vaha C Programming Language 3 24-May-2005 19:21
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 08:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:36.


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