Hi again abu... that's better - we never know what sort of danger downloads bring.
So where are you going to start with a flow chart?
It looks like this program whould at least have a circular 'blob' at the start with another one with an incoming arrow at the end.
I suspect you might have a couple of decision diamonds and arrows in and out too.
START
|
V
input n1
|
V
is n1 < 0?
| |
V V
yes no
: |
: V
print 'negative'
There you are, I've just about done your assignment for you. Probably better/erasier to use Word or Flow Charter software if you can or even a pencil and paper.
#include<iostream.h>
#include<conio.h>
main(){
int mnumber,guess,tries=1;
clrscr();
cout<<"Enter the magic number:";
cin>>mnumber;
clrscr();
for(;tries<100000;tries++)
{
cout<<"\nEnter your guess:";
cin>>guess;
if(guess==mnumber)
{
cout<<"You're right! You've got the magic number!";
break;
}
elseif (guess<mnumber)
{
cout<<"Your guess is TOO LOW!";
}
else
{
cout<<"Your guess is TOO HIGH!";
}
}
cout<<"\n\nNumber of Tries:"<<tries<<"";
cout<<"\n\nThank you for using this program!";
getch();
return 0;
}
3. loop starts at try 1 with a limit of 1000000 tries
4. input a guess
5. decide on size compared to actual value or whether successful and loop back or finish
yeah that's ok but you don't do it that way. for loops are made up of a decision diamond, program step rectangle and path arrows. I can't draw it for you here but you can get plenty of examples if you google "c++ for loop"
Great improvement.
- u need arrowheads at the end of every line.
- inputs are often rectangles with rounded corners.
- program steps are often rectangles with sharp corners.
Looks pretty good except you can't leave dead end branches. All you do is draw an arrow all the way to to the end or have a dashed line/arrow to an indicative end. The important thing is you can't allow a path to dangle in space - it's unfair.
#include<iostream.h>
#include<string.h>
#include<conio.h>
int main(){
clrscr();
char Username[30]="sammasangcap",Password[30]="abc123",username[30],password[30],age[2],name[60],sex[6],address[100];
unsignedint attempts =0;
do
{
cout<<"\nUsername:";
cin>>username;
if(strlen(username) <4)
{
cout<<"\nUsername length must be atleast 4 characters";
}
else
{
cout<<"\nPassword:";
cin>>password;
}
if(! ( (strcmp(username,Username) == 0) && (strcmp(password,Password) == 0)))
{
cout<<"\nInvalid Username and/or Password! Please try again!";
attempts++;
if(attempts == 3)
{
cout<<"\n\nYou exceeded the number of times that you need to input the correct username and password.\n******The system is now locked! ******";
break;
}
}
else
{
cout<<"\nLogin Succesful!";
cout<<"\nPlease input the following information:";
cout<<"\nName:";
cin>>name;
cout<<"\nAge:";
cin>>age;
cout<<"\nSex:";
cin>>sex;
cout<<"\nAddress:";
cin>>address;
cout<<"\nHi "<<name<<"! I am glad to meet you. You are a "<<sex<<" student and your age is "<<age<<". Hope to see you in "<<address<<". Thank you for using my program.";
break;
}
}while(1);
getch();
return 0;
}