Monday, November 30, 2015

// // Leave a Comment

Simple QBasic Program To Count Number Of Male And Female Students In A Class

Write a program in QBasic to count number of male and female students in class. Print out the number of males, number of females and total number of students.
 
/**
 *
 * @Author: Aghatise Osazuwa
 * Website: www.cscprogrammingtutorials.com
 *
 */ 

DIM nTotal AS Integer, nMale AS INTEGER, nFemale AS INTEGER 
DIM choice AS Integer, sex AS INTEGER, female AS INTEGER

nTotal = 0
nMale = 0
nFemale = 0

PRINT ""
PRINT "THIS PROGRAM COUNTS AND PRINTS THE NUMBER OF MALES AND FEMALES IN A CLASS"
PRINT "-------------------------------------------------------------------------"
PRINT ""

INPUT "DO you want to start (-1 to quit)"; choice

DO WHILE choice <> -1
    INPUT "Is student a male (1 = yes, 2 = no)"; sex
    IF sex = 1 THEN
        nMale = nMale + 1
    ELSE
        nFemale = nFemale + 1
    ENDIF
        
    nTotal = nTotal + 1
        
    INPUT "DO you want to continue (-1 to quit)"; choice
LOOP

PRINT ""    
PRINT "The total number of MALE students = "; nMale
PRINT "The total number of FEMALE students = "; nFemale
PRINT "The total number of students = "; nTotal

Click here to see the same program in C++.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.