How To Write A Java Progarm That Asks Number Of Female And Male Registered In Class
-
01-fifteen-2012 #1
Registered User
Count number of male person and female students?
Hello experts,
I accept this exercise where, too everything else, I need to count the numbers of male students and number of female students. How do I do that?
Thanks
-
01-15-2012 #2
Registered User
"...a computer is a stupid machine with the ability to do incredibly smart things, while figurer programmers are smart people with the ability to do incredibly stupid things. They are,in brusque, a perfect match.." Bill Bryson
-
01-xv-2012 #3
Registered User
use if statements like stahta01 says, and keep a 2 seperate variables representing male and female person students and then increment them when needed
-
01-xv-2012 #4
Registered User
This is what I did so far! When I run it, it comes out with a bulletin ".exe has stopped working". I realized the problem is somewhere in the second office.
Originally Posted by camel-human
Just what exactly I don't see. Whats wrong?Code:
void dataIn(FILE *infile, double average, studenT stud[N], char male, char female)
Lawmaking:
#include <stdio.h> #include <string.h> #include "genlib.h" #include "simpio.h" #ascertain N 100 typedef struct { char name [30]; int average; }studenT; void File(FILE*infile, FILE*outfile); void dataIn(FILE *infile, double average, studenT stud[N], char male, char female); main() { FILE * infile, *outfile; char proper noun[fifteen], lastname[25], male, female person; double average; educatee stud[North]; File(infile, outfile); dataIn(infile, average, stud, male, female); system("PAUSE"); } void File(FILE*infile, FILE*outfile) { char filein[thirty], fileout[30]; while(TRUE) { printf("Give the input file name: "); gets(filein); infile = fopen(filein,"r"); if (infile != Goose egg) { suspension; } printf("Can't open %s\n", filein); } printf("Give the output file name: "); gets(fileout); outfile = fopen(fileout, "westward"); } void dataIn(FILE *infile, double average, studenT stud[N], char male, char female) { int i, nscan, mcount, fcount; double marks[68]; char name[15],lastname[25], termch; mcount = 0; fcount = 0; while(TRUE) { nscan = fscanf(infile, "%fifteen[^,], %25[^,], %68g, %c", name, lastname, marks, &termch); if(nscan == EOF)break; if(nscan != 4 || termch != '\north') printf("Error\due north"); if (average >= 10); { strcpy(stud[mcount].proper noun, name); stud[mcount].average = average; mcount++; } } }
-
01-15-2012 #v
Registered User
In club to modify the value of a parameter passed to a part you lot must laissez passer information technology using a pointer.
This applies to pointer you wish to change.Needs to be changed.Lawmaking:
void File(FILE*infile, FILE*outfile);
One possible way isTim S.Code:
void File(FILE**infile, FILE**outfile);
"...a reckoner is a stupid motorcar with the ability to practise incredibly smart things, while computer programmers are smart people with the power to practise incredibly stupid things. They are,in brusk, a perfect lucifer.." Pecker Bryson
-
01-xv-2012 #6
Registered User
Cheers, but nevertheless I need help with the 2d function.
Code:
void dataIn(FILE *infile, double average, studenT stud[N], char male, char female) { int i, nscan, mcount, fcount; double marks[68]; char name[15],lastname[25], termch; mcount = 0; fcount = 0; while(TRUE) { nscan = fscanf(infile, "%15[^,], %25[^,], %68g, %c", name, lastname, marks, &termch); if(nscan == EOF)pause; if(nscan != 4 || termch != '\north') printf("Error\northward"); if (average >= 10); { strcpy(stud[mcount].name, name); stud[mcount].average = boilerplate; mcount++; } } }
-
01-15-2012 #7
spurious conceit
That should be %lg (or lf) for a double. I don't recollect there is a point in using a max length (68) as the value will be truncated regardless.Lawmaking:
nscan = fscanf(infile, "%15[^,], %25[^,], %68g, %c", proper name, lastname, marks, &termch);
Source: https://cboard.cprogramming.com/c-programming/145224-count-number-male-female-students.html
Posted by: randallextelown67.blogspot.com

0 Response to "How To Write A Java Progarm That Asks Number Of Female And Male Registered In Class"
Post a Comment