Showing posts with label sample program. Show all posts
Showing posts with label sample program. Show all posts

Problem:

Create a C + + program to determine whether a number is the user input is odd or even number.

Analysis:

To create C + + program that determines the odd or even number, we must first know how to distinguish between odd and even numbers. Examples of odd numbers are 1, 3, 5, 7, 9 and so on. Examples of even number is 2, 4, 6, 8 and so on. Before you can determine the odd and even numbers, you should know the rest of the division operator (MOD) / modulus

Division remainder operator yields the remainder quotient, for more details see the following example:

4 mod 2 0 (clear)
5 mod 2 1 (odd)
12 mod 4 0 (clear)
15 mod 2 1 (odd)


Program :
If created in C + + program, then the following is a C + + program to determine odd or even numbers.

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
clrscr();
int bil, sisa;
cout<<"Insert some value : "; cin>>bil;
sisa = bil % 2;
if(sisa == 0)
cout<<<" even number"< else cout<<<" odd number"< getch();

Program c++ for selection (1)

Here is an example of C + + program that uses the IF statement. The problem is as follows: By using the IF statement, 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 <stdio.h>
# include <conio.h>
#include <iostream.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 ();
}



Recent Entries