Tuesday, 20 August 2013

Program In C Language To Find Number Is Prime or not.

//Program to find number is prime or not




Explanation:-

In this Program, we used some terms that are used in almost every program of C.
Let understand the meaning of these terms.

1.  int num,i,n;

num 
 Is a variable of Integer type used to store an integer constant.



i
 Is a variable of Integer type used to store an integer constant.



 Is a variable of Integer type used to store an integer constant.


Variable:- An entity (it can be anything which exists in real world) that may vary during program execution is known as variable.
Variable names are the names given to locations in memory.

2.  if(num==1)
        
if() 
 If statement is a conditional branching statement. In conditional  branching statement a condition is evaluated.
 if(condition)
 statement;
 If the condition is evaluated and found to be true, the statement  following the "if" is executed. If false, the following statement is  skipped.

== 
 It is a relational operator which evaluates the relationship between two  operands and returns "true" or "false"

3. for(i=2;i<num;i++)

for() 
 For loop allow us to do the same thing number of times. Therefore, a  starting condition, a final condition and a condition to move on the  next value is given. Its syntax is given as:
 for(start value; continue or end condition; increase/decrease value)
 statement;

i=2 
 It is a start value.

i<num 
 It is a continue or end condition.

i++ 
 It is a increase value.

4. n=num%i;

n=num%i 
 It divides the num by i and stores the remainder in n.

5. break;

break 
 Break statement is used to interrupt the normal flow of program  immediately. It skip statements inside the loop and terminate the loop immediately.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.