home   |   contact us   |   sitemap   |   advertising Free Online Games
Free MMORPG

The Free MMORPG Games- Free MMORPG - P2P Games - Open Beta - Closed Beta - Browser Based - Non-English - Other Free Games - Top 50


Go Back   Onrpg Free MMORPG Forums > Development > General Programming

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-06-2007, 05:05 PM   #1 (permalink)
Sun? What Sun?
 
TheGW's Avatar
 
Join Date: Apr 2007
Location: Tacloban City, Leyte, Republic Of The Philippines
Posts: 950
Reputation: 17
Send a message via Yahoo to TheGW
MMOFaces Profile: None Yet
Red face Please Help Me Defend My Program...

We Got A Coming Defence In Our CSCI01 Subject, And I'm A Bit Scared, I Don't Even Know How To Explain, Can Anyone Please Help Me Explain, Even Just The Basics...

I've Been Working These For More Than 3 Days, Staying Up Late, And Burning Oil...

Quote:
#include<string.h>
#include<ctype.h>

main()
{int count1,count2,y,count3,a,b;
char name[100][80]={0},temp;
char pass[20]="TOBLERONE",password[20];
float grade[100],qui1,quiz2,quiz3;

clrscr();

count3=0;
a=15;
b=10;

do
{gotoxy(a,b);
printf("DE CODE VAN DE VEILIGHEID: ");
gets(password);

count3++;
a++;
b++;

if(strcmp(pass,password)==0)
{gotoxy(a,b);
printf("\n\t\tTOEGELATEN HET WOORD VAN DE PAS: VERLEENDE TOEGANG!");
BREAK;
}

else
{if(count==3)
{gotoxy(a,b);
printf("\n\t\WAARSCHUWING!: AANDACHT! , WORDT UW TOEGANG ONTKEND!");
}
}
}while(count3<3);

getch();


clrscr();

gotoxy(5,1);
printf("STUDENTS NAME");

gotoxy(25,1)
printf("QUIZ 1")

gotoxy(35,1)
printf("QUIZ 2")

gotoxy(45,1)
printf("QUIZ 3")

gotoxy(60,1)
printf("STUDENTS AVERAGE");

for(count1=0,count2=0,y=2,count1=5;count1<=100;cou nt++,y++)
{gotoxy(8,y);
scanf("%s",&name[count2]);

do
{temp=getch();

if(isalpha(temp))
{printf("%s",temp);
name[count1][count2]=temp;
count2++;
}
}while(temp!='\r' && count2<=100 && temp!='0');
}
if(temp == '0')
break;

gotoxy(27,y);
scanf("%f",&quiz1);

gotoxy(37,y);
scanf("%f",&quiz2);

gotoxy(47,y);
scanf("%f",&quiz3);

grade[count2]=(quiz1+quiz2+quiz3)/3;

gotoxy(65,y);
scanf("%0.2f",grade[count2]);
}
getch();
}
This Program Is Used Like A Instructor's Class Record, Inputting The Student's Name, 3 Quiz Scores, And Outputing The Average...
Whenever Our Instructor Press "0", The Program Will Stop And Output Everything... But Were UnAble To Do It...

Please Help Me...
__________________
Some said, "Don't play childish games like Pokémon". I was frustrated, and I shouted, "Dialga!; Roar Of Time!".
- - - - -
R.O.S.E. OnLine Evolution: http://www.onrpg.com/boards/95254.html UpDated!
RAGNARÖK OnLine RPG™: http://www.onrpg.com/boards/82072.html UpDated!


TheGW is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2007, 11:29 PM   #2 (permalink)
McFox Sandwich
 
Eriond's Avatar
 
Join Date: May 2006
Location: Canada
Posts: 455
Reputation: 17
Send a message via MSN to Eriond
MMOFaces Profile: None Yet
Default

I believe it has something to do with gets. I remember back in my C++ class, if you used gets with cin, bad things happened, and I think cin is an extension of scanf. Try only using scanf or gets, but not both, and see what happens.
__________________
This was a triumph. I'm making a note here, HUGE SUCCESS.

Outsider
3D Space Shooter/RPG in Development
http://advena.awardspace.com/
Eriond is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2007, 04:00 AM   #3 (permalink)
Sun? What Sun?
 
TheGW's Avatar
 
Join Date: Apr 2007
Location: Tacloban City, Leyte, Republic Of The Philippines
Posts: 950
Reputation: 17
Send a message via Yahoo to TheGW
MMOFaces Profile: None Yet
Unhappy Hmm...

I Also Forogt To Tell, That The Panelists Wants Us To Explain Every Detail (Not Just As A Whole), And Explain What Happens...

Please I Just Need Some Help...
__________________
Some said, "Don't play childish games like Pokémon". I was frustrated, and I shouted, "Dialga!; Roar Of Time!".
- - - - -
R.O.S.E. OnLine Evolution: http://www.onrpg.com/boards/95254.html UpDated!
RAGNARÖK OnLine RPG™: http://www.onrpg.com/boards/82072.html UpDated!


TheGW is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2007, 04:30 AM   #4 (permalink)
McFox Sandwich
 
Eriond's Avatar
 
Join Date: May 2006
Location: Canada
Posts: 455
Reputation: 17
Send a message via MSN to Eriond
MMOFaces Profile: None Yet
Default

Quote:
Originally Posted by TheGW View Post
I Also Forogt To Tell, That The Panelists Wants Us To Explain Every Detail (Not Just As A Whole), And Explain What Happens...

Please I Just Need Some Help...
Oh, ok no problem. I'll go through it.

Code:
#include<string.h>
#include<ctype.h>
These take files (header files) that are stored with the program you're writing the code with, and put them at the top of your program. (It allows you to use all the functions like gotoxy and printf, because those functions are actuallly stored in other files, which the includes can locate)

Code:
int main()
{
....
}
This is your main function. It's called the entrypoint to your program. It's where the program starts.


Code:
int count1,count2,y,count3,a,b;
char name[100][80]={0},temp;
char pass[20]="TOBLERONE",password[20];
float grade[100],qui1,quiz2,quiz3;
These are your variables declarations. They take small segments of memory and allow you to use them as either integers, characters or floating point numbers.

Code:
clrscr();
This just clears the console window.

Code:
count3=0;
a=15;
b=10;
These put numbers to your variables. They set the small segments of memory to a specific value.
Code:
do
{
....
} while(count3<3);
This just means that the stuff inside this will be executed, then, at the end, if Count3 is less than 3, it'll loop back to the beginning and start again, and keep doing this until count is greater than or equal to 3.

Code:
gotoxy(a,b);
This is the gotoxy function. It makes it so that whenever you try to put something in the console window, it goes to the x and y position that you set it to.

Code:
printf("DE CODE VAN DE VEILIGHEID: ");
This just puts into the console window whatever you typed into it, at the position specified by gotoxy, or just, by default, at 0,0, in the top left hand corner of the window.

Code:
gets(password);
This one's slightly more complicated. Gets takes the user's input, and puts it into the character array variable specified (also called a string variable). So in this case, if the user types in "TOBLERONE", it'll get stored in the variable password. password[0] is equal to 'T', etc..

Code:
count3++;
a++;
b++;
This just means take the variable and add one to it.

Code:
if(strcmp(pass,password)==0)
{
....
}
This means, compare the variables pass and password. If the function returns 0 (which means, if the two strings are equal), then proceed with the code inside the square brackets.

Code:
BREAK;
This means stop the loop that it's currently in, and skip to the end. (in this case the while(count3<3) loop.

Code:
else
{
...
}
Just means that if the if statement above is NOT 0, then do the stuff in square brackets.

Code:
printf("\n\t\tTOEGELATEN HET WOORD VAN DE PAS: VERLEENDE TOEGANG!");
The \n is a new line character, it means skip one line down on the console window. The \t is a tab character, it means move over a certain amount of spaces.

Code:
getch();
Kind of a way of pausing the program, it means let the user make a single keystroke before continuing.

Code:
for(count1=0,count2=0,y=2,count1=5;count1<=100;cou nt++,y++)
Like a while loop, except when the loop starts, this makes count1 = 0, etc.. and will loop until count1 is less than or equal to 100, and every time the loop finishes it'll add one to count and one to y.

Code:
scanf("%s",&name[count2]);
This means take input from the user and put it into the string specified. the "%s" means string, the & sign before the variable means the address of the variable (where it is in memory, so basically scanf puts the value INTO the address in memory, instead of into the value of the data in memory (so like into some random obscure location instead of "into" the number 5). the [] after name mean that you're putting it into count2 element of the variable array. An array is a big bunch of variables all put together. char name[100][80] that's an array of 8000 characters, each character string is 80 in length, and there are 100 of them.

Code:
temp=getch();

if(isalpha(temp))
This puts the value that user types in into the variable temp. Then the if statement checks to see if the character that was put in is with in a certain range (I.E., if it's a letter, like 'A'). If the user types in A, it'd return true, if the user typed in the number 2, it would return false.

Code:
printf("%s",temp);
This just prints the string that's located in the temp variable... uh... yeah. That's actually wrong. That should be %c, for a single character, because temp is only one variable, and not a bunch of them. You should change that.

Code:
scanf("%f",&quiz1);
This takes the user's input in the form of a floating point number (I.E. 2.5453), and puts it into the address of quiz1.

Okay! I think that's everything. Hope it answers your questions!
__________________
This was a triumph. I'm making a note here, HUGE SUCCESS.

Outsider
3D Space Shooter/RPG in Development
http://advena.awardspace.com/
Eriond is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2007, 07:38 AM   #5 (permalink)
Sun? What Sun?
 
TheGW's Avatar
 
Join Date: Apr 2007
Location: Tacloban City, Leyte, Republic Of The Philippines
Posts: 950
Reputation: 17
Send a message via Yahoo to TheGW
MMOFaces Profile: None Yet
Talking O.m.g.

Sure Is It's Everything...
I Wanna Cry, Thanks For Really Helping Me.
It Sure Is A Lot Of Things To Remember.

Thanks...
Thanks...
Thanks...
Thanks...
Thanks...

Many Thanks...
__________________
Some said, "Don't play childish games like Pokémon". I was frustrated, and I shouted, "Dialga!; Roar Of Time!".
- - - - -
R.O.S.E. OnLine Evolution: http://www.onrpg.com/boards/95254.html UpDated!
RAGNARÖK OnLine RPG™: http://www.onrpg.com/boards/82072.html UpDated!


TheGW is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2007, 10:41 PM   #6 (permalink)
McFox Sandwich
 
Eriond's Avatar
 
Join Date: May 2006
Location: Canada
Posts: 455
Reputation: 17
Send a message via MSN to Eriond
MMOFaces Profile: None Yet
Default

Lol, don't worry about it. It took me like 10 mins to type up, it's not that big a deal

Thanks for the thanks


If you ever have any questions, just ask!
__________________
This was a triumph. I'm making a note here, HUGE SUCCESS.

Outsider
3D Space Shooter/RPG in Development
http://advena.awardspace.com/
Eriond is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2007, 12:17 AM   #7 (permalink)
Sun? What Sun?
 
TheGW's Avatar
 
Join Date: Apr 2007
Location: Tacloban City, Leyte, Republic Of The Philippines
Posts: 950
Reputation: 17
Send a message via Yahoo to TheGW
MMOFaces Profile: None Yet
Talking Hehe...

Quote:
Originally Posted by Eriond View Post
Lol, don't worry about it. It took me like 10 mins to type up, it's not that big a deal

Thanks for the thanks


If you ever have any questions, just ask!
Sure I'll Ask Soon...
Thanks Again!
__________________
Some said, "Don't play childish games like Pokémon". I was frustrated, and I shouted, "Dialga!; Roar Of Time!".
- - - - -
R.O.S.E. OnLine Evolution: http://www.onrpg.com/boards/95254.html UpDated!
RAGNARÖK OnLine RPG™: http://www.onrpg.com/boards/82072.html UpDated!


TheGW is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:14 AM.

Forums Section List
Main Category Free Games Online Games Upcoming Games Online Games Upcoming Games
General Free MMORPG Fiesta Online    Maple Story Guides Trickster DOMO - Dream of Mirror Online
RolePlaying Free MMO & MMOFPS Conquer Online    Maple Story Buy/Sell/Trade WarRock Online Seal Online
Newbie Zone Korean/Foreign Games DragonGem Lunia World of Warcraft Age of Armor
  Browser/MUDs FlyFF Ragnarok Online Other Games Exteel
  Single Player RPGs Ghost Online Rakion    Rappelz Infinity
  Free MMORPG Requests Guildwars Runescape    Final Fantasy XI Cabal Online
    Gunz Online Scions of Fate (YulGang)    Goonzu Online Granado Espada
    Maple Story Silkroad    Gunbound Nostale



Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Onrpg, Copyright ©2003-2007, BlueCastle Media

Copyright © 2004-2007 BlueCastle Media