C + + Program To Determine Passed / Not Passed

Kamis, 17 November 2011
Here is an example of C + + program that uses the IF statement. Because is as follows:

    
By using the IF statement, create a program to determine whether a student "Passed" or "Not Passed" by The Theory and Practice Values ​​are entered by the user. Terms Graduating students will be if the average value of at least 60 and at least 55 Value Practice.

    
Eg = 100 Value Theory, Practice Value = 50 then result = Disqualified. For example Value Theory = 40, value = 90 then the result Practice Passed.
Looking at the above questions, then we know that there are two, namely the value of their input Theory and Practice Values. Students will be based on both average value and the value of the theory. So first we have to find the average value of first is by adding the value of theory and practice and then divided by two. More C + + program to answer the questions above are as follows:01 # include <iostream>02 # include <conio.h>0304 void main ()05 {06 clrscr ();07 float theory, practice, rata2;08 court <<"Enter a value theory:";09 cin>> theory;10 court <<"Enter the value of practice:";11 cin>> practice;Rata2 = 12 (theory + practice) / 2;13 if (rata2> = 60 & & practice> = 55)14 {15 court <<"Passed";16}17 else18 {19 court <<"Not Passed";20}21 getch ();22}
Explanation of Program:
First we create a variable that is 3 pieces of theory, practice and rata2, the three of us make with the float type data type can store fractional values. This is to anticipate the next time the division generating value fractions. Next 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 amount of theory and practice divided by two. Then by using the IF statement, the program will perform rata2 testing whether the value of at least 60 and a minimum of 55 practices. Remember here the testing of the IF using the operators AND, so the two expressions must be TRUE.
If the result is correct, it will show "Pass" and vice versa if it is wrong it will show "Not Passed".

0 komentar: On C + + Program To Determine Passed / Not Passed

Posting Komentar

Grab this Widget ~ Blogger Accessories
 
bottom