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.

Thursday 15 August 2013

How To Perform Addition In C Language

//Program to perform addition in 'C' with explanation



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 a,b,c;

int 
 Is a Integer data type whose range depends upon the compiler.
 For a 16-bit compiler like Turbo C or Turbo C++ the range is -32768 to +32767.
 For a 32-bit compiler like visual studio or gcc the range is -2147483648 to +2147483647.

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



b
 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.

a,b,c 
 Commas between variables are used to define two or more variables  in a line. Otherwise, We have to write it like this:
 int a;
 int b;
 int c;

2.  scanf("%d",&a);
        
scanf() 
 Is used to read input from the user.

%d 
 Defines that input is of integer type.

&a 
 Defines that input is stored in variable 'a'.

3. c=a+b;
       
c=a+b 
 This statement add the value of two variables 'a' and 'b'.
 '+' perform addition.
 '==' used to store the addition in another variable called 'c'.

Wednesday 7 August 2013

How To Make Simple Hello Program With Explanation

//Program to print “Hello” with the meaning of each word



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.  #include<stdio.h>

#include 
 Is a preprocessor directive (here it is used for File Inclusion.  Hence, it is called as file inclusion preprocessor directive.)

         
stdio.h 
 Is the name of standard input/output header file (.h extension  represent that it is a header file.)


2.  #include<conio.h>

conio.h 
 Is a console input output header file. It manage the console i/o  functions. Such as- printf is used to display output on the  screen. And, scanf is used to read input from the user. 

3.  void main()
         
void 
 Is the data type. It does not return any value.
 Instead of void, we can also write 'int' but int return value. So,  we have to write 'return 0;' before 'getch();' 0 indicates success.

         
main() 
 Represents a function. All statements that belong to program are  written inside the main function.


4.  {}
         
{} 
 The statements written inside the main() function are enclosed  within a pair of braces {}.


5.  clrscr();

clrscr() 
 Is used to clear the output screen.



 Is used to terminate a statement.


6.  printf("Hello");
        
printf("Hello") 
 Is used to display output on the screen. This command displays  'Hello'.


7.  getch();
       
getch() 
 It accepts a character from user. Thus, it helps to the user to see  output by waiting to enter a character from keyboard.

Thursday 1 August 2013

Things To Know

  • C is developed by Dennis Ritchie.
  • C is a Middle Level Language.
  • C program is often known as Source Code.
  • In C, statements are executed in the sequence they have written.
  • The symbol ';' used to terminate a statement.
  • All statements are entered in small case letters.
  • No blank spaces are allowed within a variable, constant or keyword.

 

PREPROCESSOR:- 

  • Before a C program is compiled it is passed through another program called preprocessor.
  • Preprocessor works on the source code and creates 'Expanded Source Code'.
  • Preprocessor offers several features called preprocessor directives or preprocessor command such as #include is a preprocessor directive.
  • Each preprocessor directive begins with a # symbol.
  • Preprocessor directives are:-
  • Macro expansion
  • File inclusion
  • Conditional Compilation
  • Miscellaneous directives