write a program in QBASIC to find the percentage of boys and girls in the class
Answers
Answered by
3
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
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
Similar questions
English,
8 months ago
India Languages,
8 months ago
English,
1 year ago
Physics,
1 year ago
Biology,
1 year ago