Rabu, 13 April 2011

Program C + + To Determine Passed / Not Passed

Ex matter: 1. create a program to determine whether a student is "Passed" or "No Pass" on the basis of Value Theory and Practice Value entered by the user. Terms of students would graduate if the average value of at least 60 and minimum value of Practice 55. Eg = 100 Value Theory, Practice Value = 50 then the result = Disqualified. For example, Value Theory = 40, Value Practice = 90 then the result is Passed. Seeing the above question, then we know that there are two inputs namely Value Theory and Practice Value. Students will be based on two things: the average value and value theory. So first we must find the average value of first is by adding up the value of theory and practice and then divided by two. Program C + + more to answer the questions above are as follows: # Include <iostream> # Include <conio.h>
void main () {clrscr (); float the theory, practice, rata2;
 
court <<"Enter the value of theory:";
 
cin>> theory;
 
court <<"Enter the value of practice:";
  
cin>> practice;
  
rata2 = (theory + practice) / 2;
 
if (rata2> = 60 & & practices> = 55) {
 
court <<"Passed";} else {
 
court <<"No Pass";}
 
getch ();}
Program Explanation: First we create 3 pieces of variables, namely the theory, practice and rata2, the three of us make with the float type data type can store fractional values. This is to anticipate when will the results of the division produces a float value. Furthermore, the program will ask for input from the user to the theory and practice. The next step the program will calculate the value rata2 ie the number of theory and practice are divided in two. Then by using the IF statement, the program will perform testing whether rata2 value of at least 60 and practice at least 55. Remember here in the IF part of the test using the operators AND, so the two expressions must be TRUE.
If the result is correct, it will display "Passed" and vice versa if it is wrong it will display the "No Passing".

Tidak ada komentar:

Posting Komentar