Swap Of Two Numbers

Swap Of Two Numbers

Swap of two numbers program in C
This is our first program in C programming language. This C program will print the text
“Hello World!” on the console output screen. In this post we will learn how to 
write a C Program and explore each statements in this C Program and many more.

                                                                 

/*Swap of two numbers*/
#include<stdio.h>
#include<conio.h>
int main()
{
     int num1,num2;
      clrscr();
      printf("Enter the first number       :”);
           scanf("%d",&num1);
      printf("Enter the second number :”);
           scanf("%d",&num1);
      printf("Before swapping first number        :%d\n,num1);  
      printf("Before swapping second number :%d\n,num2); 
                /*logic of swapping*/

                     num1=num1+num2;
                     num2=num1-num2;
                     num1=num1-num2; 
      printf("After swapping first number        :%d\n,num1);  
      printf("After swapping second number :%d\n,num2); 
      getch();
     return(0);
}

Output: 
Enter the first number        :11 
Enter the second number  :34
Before swapping first number       :11
Before swapping second number :34
Before swapping first number       :34
Before swapping second number : 11
 
  


Explanation Of Each Statements In The Program:-
To learn any programming language, practical is must important than others factors. First of
all we learn and understand the language and then we implements, each things related to 
the language and explore about it. After all we are interested in making products (Software)
by using that language.
Every programmer and learner first of all print Hello world! Program while they start learning
a programming language. So we are going to print Hello World! on the console output
screen.
#0: \*First program in C to print Hello World! text the console output screen */
This statement are called comment. We write comment in C programming language by using /* */ this symbols and writes somethings message within these symbols. We write the
comment about program and statement of that program to remember written statements and logic after sometimes. The comments have lot’s advantages in the programming, we
will learn more about comments in the others post.
#1: #include <stdio.h>
stdio.h is called header file which contains declarations of standard input, output related
library functions of the C programming language, this statement is write here to tells the
compiler to include the declarations of all standard input, output library functions which are
stored inside the header file stdio.h. We will learn more about header file in the other post.
#2: int main()
 main is a pre-declared functions in the C language which is defined by the programmer
 while writing a program, to run or execute the program.The main function is declared in the
 C language but we can define in our way. The main function is necessary to execute or run
 the program, without main function we cannot execute our program. The main function is
 starting point to the start executing our program. We will learn more about function and their declaration in the others post.
#3: printf(“Hello World!”);
“Hello World!” is sequence of the characters that are called string in the C programming
 language that are pass to the printf function to display text "Hello World!" on the console
 output screen(monitor). printf is a library function that is responsible to display text on the 
 standard output device in the C programming language. printf function is declared in header
 file stdio.hWill will learn more about input and output related function in the other post.
#4: { }
 These symbols are used to create blocks of function, if ,if-else, looping, switch, structure ,union others statements in the C programming language. The block are collection of codes 
 or statements to a particular function and others statements.
 #5: return 0;
 return (0);this statement is returning the control of this program to the calling function or
 system that is our operating system because main function is called by the operating   system in the C programming language. We will learn more about calling function in the
  others post. with value 0 return value 0 represent that’s program’s execution complete
  successfully.
  




Check wheather A Number is Even Or Odd

Check wheather A Number is Even Or Odd

Check whether a number is even or odd program in C
This is our first program in C programming language. This C program will print the text
“Hello World!” on the console output screen. In this post we will learn how to 
write a C Program and explore each statements in this C Program and many more.

                                                                 

/*Check whether a number is even or odd*/
#include<stdio.h>
#include<conio.h>
int main()
{
     int number;
      clrscr();
      printf("Enter the number :”);
         scanf("%d",&number);
              if(number%2==0)
                  {
                        printf("%d is an even number ",number);
                  }
              else
                 {
                        printf("%d is an odd number ",number);
                 }
     getch();
     return(0);
}

Output:  

Enter the number:12
12 is even number


Explanation Of Each Statements In The Program:-
To learn any programming language, practical is must important than others factors. First of
all we learn and understand the language and then we implements, each things related to 
the language and explore about it. After all we are interested in making products (Software)
by using that language.
Every programmer and learner first of all print Hello world! Program while they start learning
a programming language. So we are going to print Hello World! on the console output
screen.
#0: \*First program in C to print Hello World! text the console output screen */
This statement are called comment. We write comment in C programming language by using /* */ this symbols and writes somethings message within these symbols. We write the
comment about program and statement of that program to remember written statements and logic after sometimes. The comments have lot’s advantages in the programming, we
will learn more about comments in the others post.
#1: #include <stdio.h>
stdio.h is called header file which contains declarations of standard input, output related
library functions of the C programming language, this statement is write here to tells the
compiler to include the declarations of all standard input, output library functions which are
stored inside the header file stdio.h. We will learn more about header file in the other post.
#2: int main()
 main is a pre-declared functions in the C language which is defined by the programmer
 while writing a program, to run or execute the program.The main function is declared in the
 C language but we can define in our way. The main function is necessary to execute or run
 the program, without main function we cannot execute our program. The main function is
 starting point to the start executing our program. We will learn more about function and their declaration in the others post.
#3: printf(“Hello World!”);
“Hello World!” is sequence of the characters that are called string in the C programming
 language that are pass to the printf function to display text "Hello World!" on the console
 output screen(monitor). printf is a library function that is responsible to display text on the 
 standard output device in the C programming language. printf function is declared in header
 file stdio.hWill will learn more about input and output related function in the other post.
#4: { }
 These symbols are used to create blocks of function, if ,if-else, looping, switch, structure ,union others statements in the C programming language. The block are collection of codes 
 or statements to a particular function and others statements.
 #5: return 0;
 return (0);this statement is returning the control of this program to the calling function or
 system that is our operating system because main function is called by the operating   system in the C programming language. We will learn more about calling function in the
  others post. with value 0 return value 0 represent that’s program’s execution complete
  successfully.