Showing posts with label Program. Show all posts
Showing posts with label Program. Show all posts

Monday, 24 September 2018

Program to calculate electricity bill of a user in different cases in C

#include <stdio.h>
#include <conio.h>
void main ()
{
char name[25];
int choice;
float cahrge1,charge2,charge3,charge4,charge5,unit1,unit2,unit3,unit4,unit5;
printf ("\n enter name of user:");
scanf ("%s", name);
printf ("\n you can perform following operation:");
printf ("\n 1. below 83.33:");
printf ("\n 2. above 83.34 to 100:");
printf ("\n 3. above 100 to 200:");
printf ("\n 4. above 200 to 300:");
printf ("\n 5. above 300:");
printf ("\n enter your choice:"):
scanf ("%d", &choice);
switch ( choice )
{
       case 1:
       printf ("\n enter value of units:");
       scanf ("%d", &unit1);
       printf ("\n Energy charge is 50:");
break;
       case 2:
       printf ("\n enter value of units:");
       scanf ("%d", &unit2);
       charge2= 0.6*unit2;
       printf ("\n Charge=%d",charge2);
break;
       case 3:
       printf ("\n enter value of units:");
       scanf ("%d", &unit3);
       charge3=( 0.8*(unit3-100)+60;
       printf ("\n Charge=%d",charge3);
break;
       case 4:
       printf ("\n enter value of units:");
       scanf ("%d", &unit4);
       charge4=( 0.9*(unit4-200)+140);
       printf ("\n Charge=%d",charge4);
break;
       case 5:
       printf ("\n enter value of units:");
       scanf ("%d", &unit5);
       charge5=( 0.9*(unit5-300)+230);
       charge5=charge5+0.15*(charge5);
       printf ("\n Charge=%d",charge5);
break;
default:
        printf ("\n Have a nice day:");
}
getch ();
}




Saturday, 15 September 2018

Program to do binary search of element in C

What is searching ?

It is defined as find data of a element. We use different types of searching techniques for searching an element.
               Here we use binary search techniques in C.

Program to do binary search of element in C 

#include<conio.h>
void main ()
{
int data[10],beg,mid,end,item,lb,ub,i;
clrscr ();
printf ("\n Enter 5 element in selected order:");
scanf ("%d", &item);
beg=0;
end=4;
mid=(beg+end)/2;
while(beg<=end && data[mid]!=item)
{
      if (item>data[mid])
     {
      beg=mid+1;
      }
      else
       {
      end=mid-1;
       }
      mid=(beg+end)/2;
}
if(beg<end)
{
   printf("\n location = %d",mid+1);
}
else
{
   printf("\n unsuccessful:");
}
getch ();
}

OUTPUT ::  Enter 5 element in selected order = 25,45,65,75,85

                 ITEM SEARCHED ; 45

Sunday, 29 July 2018

Program to input number from user ( negative or positive ) calculate addition of only negative number

Using while loop ::

#include <stdio.h>
void main ()
{
int a ;
int sum = 0 ;
clrscr () ;
while ( a ! = 0 )
{
printf ("\n Enter a number:") ;
scanf ("%d", &a) ;
sum = sum + a ;
a-- ;
}
printf ("\n %d", sum) ;
getch () ;
}

Using for loop ::

#include <stdio.h>
void main ()
{
int a ;
int sum = 0 ;
clrscr () ;
for ( ; a != 0 : a-- )
{
printf ("\n Enter a number:") ;
scanf ("%d", &a) ;
sum = sum + a ;
}
printf ("\n %d", sum) ;
getch () ;
}

Output ::

Enter number :   5 , 6 , -7 ,-8 
sum =  -7 + -8 = -15
Enter a number : 5 , 6
output = nothing 

Program to find maximum of three number using user define function in C

A function can be define by the user as per the requirement of the user or programmer . To implement
a user define function , a programmer must contain the following three statement .

1. Function declaration or function prototype 

2. Function call statement

3. Function definition

Program of find maximum of three number using user define function in C

#include <stdio.h>
int max ( int , int , int ) ;                                                                                                                      void main () ;
{
int a , b , c ;
clrscr () ;
printf ("\n Enter value of a:") ;
scanf ("%d", &a) ;
printf ("\n Enter value of b:") ;
scanf ("%d", &b) ;
printf ("\n Enter value of c:") ;
scanf ("%d", &c) ;
d = max ( a,b,c ) ;
printf ("\n maximum number is %d",d) ;
getch () ;
}
int max ( int a , int b , int c ) 
{
if ( (a>b) && (a>c) )
return a ;
else if ( (b>a) && (b>c) )
return b ;
else
return c ;
}

This is program for finding maximum of three number in C using user define function. Here first of all we have to input three number from the user and write function call statement and print the value of maximum and outside the main function the function definition is written where the execution of program is takes place and output goes again to the function call statement where it is print on the output screen.



Saturday, 28 July 2018

Difference between while statement and do while statement used in C

While statement ::

Syntax :: (1)  while ( condition )
                 statement ;

               (2) while ( condition )
                    {
                     statement 1 :
                        "
                        "
                    }

Do while statement ::

Syntax ::   do 
                 {
                 statement 1 :
                     "
                     "
                     "
                  } while ( condition ) ;

What is difference between while and do while?

As per syntax property , in case of while statement first of condition is checked and and if the condition is true then execution of number of statement written within pair of { } takes place. If the condition is false the execution of number of statement written under the condition of while loop is not possible.
                     On the other hand in case of do while statement first of all execution of number of statement takes place and after executing once the condition is checked further if condition is true then execution of statement within do while is possible otherwise execution of statement is not possible.
              It means in case of while statement the execution of statement or number of statement is always condition dependent . 
                                                In case of do while statement the first execution is always condition independent. it is because of the syntax property of while and do while statement. 

Uses of do while in a program ::

#include <stdio.h>
void main ()
{
int a=1 ;
clrscr () ;
do
{
printf ("%d", a) ;
a++ ;
} while ( a <= 10 ) ;
getch () ;
}

Friday, 27 July 2018

Program to check strong number in C

What is strong number ?

A Number is called strong number if the sum of factorial of it digits is equal to itself.

Example :  145

Program to check strong number ::

#include <stdio.h>
void main ()
{
int n , add = 0 , a , i , temp ;
clrscr () ;
printf ("\n Enter a number:") ;
scanf ("%d", &n) ;
temp = n ;
while ( n )
{
i = 1 ; 
fact = 1 ;
a = n % 10 ;
while ( i <= a )
{
fact = fact * i ;
i++ ;
}
add = add + fact ;
n = n / 10 ;
}
if (  add = temp )
{
printf ("\n it is strong number:") ;
else
printf ("\n it is not strong number:") ;
getch() ;
}


This is a program to check a given number is strong number or not . Here we have to input a number from the user and then apply condition for strong number.

Output screen ::

Enter a number :: 45
It is not strong number
Enter a number :: 145
It is strong number 


Tuesday, 24 July 2018

C Program to check given number is Armstrong number or not

What are Armstrong number ?

An armstrong number is a number which is equal to the sum of digit rise to the power of total number of digit in the number.

Example :: 3 , 370 , 153

Program to check armstrong number ::

#include <stdio.h>
#include <math.h>
void main ()
{
int n , add = 0 , rem = 0 , temp , cube , pow ;
clrscr () ;
printf ('\n  Enter a number:") ;
scanf ("%d", &n) ;
temp = n ;
while ( n != 0 )
{
rem = n % 10 ;
cube = pow ( rem , 3 ) ;
add = add + cube ;
n = n / 10 ;
}
if ( add == temp )
printf ("\n Number is armstrong:") ;
else
printf ("\n Number is not armstrong:") ;
getch ()
}

OUTPUT :: (A)  Enter a number :-
                      Enter number is 153
                      Number is armstrong

                    (B) Enter a number :-
                        Enter number is 29
                       Number is not armstrong

C program of armstrong using concept of FUNCTION ::

When a program grow in size and complexity then we break that program into small module . These module are known as the function . Function increases the understandably of a program logic using function module independent logic can be defined .

Function provides the concept of modularity in a program which is best method to divide a complex program .  
#include <stdio.h>
int root ( int , int ) ;
void main ()
{
int n , add = 0 , temp , rem , word = 0 ;
clrscr () ;
printf ("\n Enter a number:") ;
scanf ("%d", &n) ;
temp = n ;
while ( temp != 0 )
{
word++ :
temp = temp / 10 ;
}
temp = n ;
while ( temp != 0 )
{
rem = temp % 10 ;
add = add + root ( remainder , digit ) ;
temp = temp / 10 ;
}
if ( n == add )
printf ("\n armstrong number:") ;
else
printf ("\n not armstrong number:") ;
}
int root ( int n , int r ) 
{
int c , p = 1 ;
for ( c = 1 : c <= r : c++ )
p = p * n ;
return p ; 
}
getch () ;
}







                    



Palindrome in C programming language as number and as string

What is palindrome?

Any word , phrase or sequence that reads the same backward and as forward .

Example ::  madam , 22 , 33 , nurse etc.

Program to check palindrome number in C.

#include <stdio.h>
void main ()
{
int n , opposite = 0 , temp ;
clrscr () ;
printf ("\n Enter a number:") :
scanf ("%d", & n) ;
temp = n ;
while ( temp != 0 )
{
opposite = opposite * 10 ;
opposite = opposite + temp%10 ;
temp = temp / 10 ;
}
if ( n == opposite )
printf ("\n Number is palindrome:") ;
else
printf ("\n Not a palindrome:") ;
getch () ;

Palindrome of sting using string functions ::

#include<stdio.h>
#include<string.h>
void main ()
{
char x [50] , y[50] ;
printf ("\n Enter a string:") ;
gets (x) ;
strcpy ( y , x ) ;
strrev ( y ) ;
if ( strcmp ( x , y ) == 0 )
{
printf ("\n Enter string is palindrome:") ;
else
printf ("\n Not a palindrome:") ;
getch () ;
}

palindrome of string without string function ::

#include <stdio.h>
#include <string.h>
void main ()
{
char word [50] ;
int first , second , last, size = 0 ;
clrscr () ;
printf ("\n Enter a word:") ;
gets ( word ) ;
while ( word [ size ] ! = 0 ) 
size ++ ;
last = size - 1 ;
second = size / 2 ;
for ( first = 0 ; first < second : first++ )
{
if ( word [ first ] != word [ last ] ) 
{
printf ("\n Not a palindrome:") ;
break ;
}
last -- ;
}
if ( first == second )
printf ("\n palindrome:") ;
getch () ;
}






Thursday, 12 July 2018

Program to calculate sub of two matrix of order m * n in C using for loop statement

/* subtraction  of matrix */
#include<stdio.h>
void main ()
{
int [5][5] , [5][5] , [5][5] ;
int  r1 , r2 , c1 , c2 ; 
int i , j ;
clrscr () ;
printf ("\n Enter the no of rows for first element:") ;
scanf ("%d", &r1) ;
printf ("\n Enter the no of column for first element:") ;
scanf ("%d", &c1) ;
printf ("\n Enter the no of rows for second element:") ;
scanf ("%d", &r2) ;
printf ("\n Enter the no of column for second element:") ;
scanf ("%d", &c2) ;
if ( ( r1!=r2) && (c1!=c2) )
{
printf ("\n subtraction is not possible:") ;
getch () ;
exit () ;
}
for ( i = 0 ; i < r1 ; i++ )                   /* Input of first matrix */
{
for ( j = 0 ; j < c1 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a {i}{j}) ;
}
}
for ( i = 0 ; i < r2 ; i++ )                    /* Input of second matrix */
{
for ( j = 0 ; j < c2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & b {i}{j}) ;
}
}
for ( i = 0 ; i < r1 ; i++ )             /* print first matrix */
{
for ( j = 0 ; j < c1 ; j++ )
printf ("%3 d", a {i}{j}) ;
printf ("\n") ;
}
for ( i = 0 ; i < r2 ; i++ )              /* print second matrix */
{
for ( j = 0 ; j < c2 ; j++ )
printf ("%3 d", b{i}{j}) ;
printf ("\n") ;
}
for ( i = o ; i < r1 ; i++ )                   /* calculation of matrix */
{
for ( j = 0 ; j < c1 ; j++ )
{
c {i}{j} = a {i}{j} - b {i}{j} ;
}
}
for ( i = 0 ; i < r1; i++ )
{
for ( j = 0 ; j < c1: j++ )
printf ("%3 d", c {i}{j}) ;
printf ("\n") ;
}
getch () ;
}

Topics used :


 In C programming array is very important topic as we discuss earlier there is two types of array in c you may read at https://www.programmingponds.com/2018/07/array-in-c.html and at https://www.programmingponds.com/2018/07/c-array-types.html . 

How to subtract two matrix :


As we know that for subtract of matrix possible there must be number of rows of first matrix should be equal to the number of rows of second matrix and the number of column of first matrix is also equal to the number of column of second matrix for this we have to apply a conditional statement .





Program to calculate sum of two matrix of order m * n in C using for loop statement

/* addition of matrix */
#include<stdio.h>
void main ()
{
int [5][5] , [5][5] , [5][5] ;
int  r1 , r2 , c1 , c2 ; 
int i , j ;
clrscr () ;
printf ("\n Enter the no of rows for first element:") ;
scanf ("%d", &r1) ;
printf ("\n Enter the no of column for first element:") ;
scanf ("%d", &c1) ;
printf ("\n Enter the no of rows for second element:") ;
scanf ("%d", &r2) ;
printf ("\n Enter the no of column for second element:") ;
scanf ("%d", &c2) ;
if ( ( r1!=r2) && (c1!=c2) )
{
printf ("\n addition not possible:") ;
getch () ;
exit () ;
}
for ( i = 0 ; i < r1 ; i++ )                   /* Input of first matrix */
{
for ( j = 0 ; j < c1 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a {i}{j}) ;
}
}
for ( i = 0 ; i < r2 ; i++ )                    /* Input of second matrix */
{
for ( j = 0 ; j < c2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & b {i}{j}) ;
}
}
for ( i = 0 ; i < r1 ; i++ )             /* print first matrix */
{
for ( j = 0 ; j < c1 ; j++ )
printf ("%3 d", a {i}{j}) ;
printf ("\n") ;
}
for ( i = 0 ; i < r2 ; i++ )              /* print second matrix */
{
for ( j = 0 ; j < c2 ; j++ )
printf ("%3 d", b{i}{j}) ;
printf ("\n") ;
}

for ( i = o ; i < r1 ; i++ )                   /* calculation of matrix */
{
for ( j = 0 ; j < c1 ; j++ )
{
c {i}{j} = a {i}{j} + b {i}{j} ;
}
}
for ( i = 0 ; i < r1; i++ )
{
for ( j = 0 ; j < c1: j++ )
printf ("%3 d", c {i}{j}) ;

printf ("\n") ;
}
getch () ;
}

Topics used :


 In C programming array is very important topic as we discuss earlier there is two types of array in c you may read at https://www.programmingponds.com/2018/07/array-in-c.html and at https://www.programmingponds.com/2018/07/c-array-types.html . 

How to add two matrix :

As you seen in the program first of all we have to declare the variable . This is program of m * n matrix but we have initialized the value of m and n otherwise there is waste of huge memory and the value of m and n must be initialized according to the use of user . 

As we know that for addition of matrix possible there must be number of rows of first matrix should be equal to the number of rows of second matrix and the number of column of first matrix is also equal to the number of column of second matrix for this we have to apply a conditional statement .



Wednesday, 11 July 2018

Multiplication of matrix of order 2 * 2 in C programming language

/* multiplication of matrix */
# include <stdio.h>
void main ()
{
int a {2}{2} , b {2}{2} , c {2}{2} ;
int i , j ;
clrscr () ;
for ( i = 0 ; i < 2 ; i++ )                   /* Input of first matrix */
{
for ( j = 0 ; j < 2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a {i}{j}) ;
}
}
for ( i = 0 ; i < 2 ; i++ )                    /* Input of second matrix */
{
for ( j = 0 ; j < 2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & b {i}{j}) ;
}
}

for ( i = 0 ; i < 2 ; i++ )             /* print first matrix */
{
for ( j = 0 ; j < 2 ; j++ )
printf ("%3 d", a {i}{j}) ;
printf ("\n") ;
}
for ( i = 0 ; i < 2 ; i++ )              /* print second matrix */
{
for ( j = 0 ; j < 2 ; j++ )
printf ("%3 d", b{i}{j}) ;
printf ("\n") ;
}
for ( i = 0 ; i < 2 ; i++ )
{
for ( i = 0 ; i < 2 ; i++ )
{
c [i][j] = 0 ;
for ( k = 0 ; k < 2 ; k++ )
{
c [i][j] = c [i][j] + a [i][k] * b [k][j] ;        /* calculation of multiplication */
}
}
}
for ( i = o ; i < 2 ; i++ )
{
for ( j = 0 : j < 2 ; j++ )
{
printf ("% 3d", c [i][j]) ;
printf ("\n") ;
}
}
getch () ;
}


Here we write program to calculate the multiplication of matrix of order 2 * 2 in C . Here we input the matrix from the user which is must contain 2 rows and 2 columns . In C programming we use 2 - D array . As we know that multiplication of matrix is possible only when number of rows of first matrix is equal to number of column of second matrix but here we have not to check because no of rows and column is fixed for both matrix .





Monday, 9 July 2018

Subtraction of matrix of order 2 * 2 in C

# include <stdio.h>
void main ()
{
int a {2}{2} , b {2}{2} , c {2}{2} ;
int i , j ;
clrscr () ;
for ( i = 0 ; i < 2 ; i++ )                   /* Input of first matrix */
{
for ( j = 0 ; j < 2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a {i}{j}) ;

}
}
for ( i = 0 ; i < 2 ; i++ )                    /* Input of second matrix */
{
for ( j = 0 ; j < 2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & b {i}{j}) ;
}
}

for ( i = 0 ; i < 2 ; i++ )             /* print first matrix */
{
for ( j = 0 ; j < 2 ; j++ )
printf ("%3 d", a {i}{j}) ;
printf ("\n") ;
}
for ( i = 0 ; i < 2 ; i++ )              /* print second matrix */
{
for ( j = 0 ; j < 2 ; j++ )

printf ("%3 d", b{i}{j}) ;

printf ("\n") ;
}
for ( i = o ; i < 2 ; i++ )                   /* calculation of matrix */
{
for ( j = 0 ; j < 2  ; j++ )
{
c {i}{j} = a {i}{j} - b {i}{j} ;
}
}
for ( i = 0 ; i < 2 ; i++ )
{
for ( j = 0 ; j < 2 : j++ )
printf ("%3 d", c {i}{j}) ;
printf ("\n") ;
}
getch () ;
}


Addition of matrix of order 2 * 2 in C

/* addition of matrix */
# include <stdio.h>
void main ()
{
int a {2}{2} , b {2}{2} , c {2}{2} ;
int i , j ;
clrscr () ;
for ( i = 0 ; i < 2 ; i++ )                   /* Input of first matrix */
{
for ( j = 0 ; j < 2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a {i}{j}) ;
}
}
for ( i = 0 ; i < 2 ; i++ )                    /* Input of second matrix */
{
for ( j = 0 ; j < 2 ; j++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & b {i}{j}) ;
}
}
for ( i = 0 ; i < 2 ; i++ )             /* print first matrix */
{
for ( j = 0 ; j < 2 ; j++ )
printf ("%3 d", a {i}{j}) ;
printf ("\n") ;
}
for ( i = 0 ; i < 2 ; i++ )              /* print second matrix */
{
for ( j = 0 ; j < 2 ; j++ )
printf ("%3 d", b{i}{j}) ;
printf ("\n") ;
}
for ( i = o ; i < 2 ; i++ )                   /* calculation of matrix */
{
for ( j = 0 ; j < 2  ; j++ )
{
c {i}{j} = a {i}{j} + b {i}{j} ;
}
}
for ( i = 0 ; i < 2 ; i++ )
{
for ( j = 0 ; j < 2 : j++ )
printf ("%3 d", c {i}{j}) ;
printf ("\n") ;
}
getch () ;
}




Thursday, 28 June 2018

C program to find average of n element of array

/* average of n element of array */
# include <stdio.h>
void main ()
{
int a[20] , sum = 0 , avg , n , i ;
clrscr () ;
printf ("\n How many number you want to print:") ;
scanf ("%d", &n) ;
if ( n > 20 )
{
printf ("\n Invalid number:") ;
getch () ;
exit () ;
}
for ( i = 0 ; i < n ; i++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", &a[i]) ;
}
for ( i =0 ; i < n ; i++ ) 
sum = sum + a[n] ;
avg = sum / n ;
printf ("\n avg = %d", avg) ;
getch () ;
}

  

Wednesday, 27 June 2018

C program to find sum of array of n element

/* program to sum of array */
# include <stdio.h>
void main ()
{
int a[20] , sum=0 , n ;
clrscr () ;
printf ("\n How many no you want to add:") ;
scanf ("%d", &n) ;
if ( n > 20 )
{
printf ("\n Invalid number:") ;
getch () ;
exit () ;
}
for ( i=0 ; i<n ; i++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", &a[n]) ;
}
for ( i=0 ; i<n ; i++ )
sum = sum + a[i] ;
printf ("\n sum =%d", sum) ;
getch () ;
}





PROCESS :

Here we have to input number of element from the user and then we have to write stubs for checking the number of element . If we use studs as number of element as 20 then we have to use element as under as 20 otherwise it becomes invalid number . 
                                                                                  As we know that array is example of static data structure in which the size of data structure can not be increased or decreased at run time of program 

Tuesday, 26 June 2018

C program to find minimum of element in array

/* Minimum of 5 element */
#include <stdio.h>
void main ()
{
int a[5] , i , min = 9999 ;
clrscr () ;
for ( i = 0 ; i < 5 ; i++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", &a) ;
}
for ( i = 0 ; i < 5 ; i++ )
{
if ( min > a[i] )
min = a[i] ;
}
printf ("\n min = %d", min ) ;
getch () ;
}


Friday, 22 June 2018

Program to find maximum of 5 element of an array in C using for loop statement

/* program of maximum */
# include <stdio.h>
void main ()
{
int a[5],i,max=0 ;
clrscr () ;
for ( i=0 ; i<5 ; i++ )
{
printf ( "\n Enter a number:") ;
scanf ("%d", & a[i]) ;
}
for ( i=0 ; i<5 ; i++)
{
if ( max < a[i] )
max = a[i] ;
}
printf ("\n max = %d", max) ;
getch () ;
}

Thursday, 21 June 2018

How to write program to find average of an array of 5 elements

/* Avg of an array */
# include <stdio.h>
void main ()
{
int a[5],i,avg ;
int sum = 0 ;
clrscr () ;
for ( i=o ; i<5 ; i++ )
{
printf ("\n Enter a number:") ;
scanf ("%d"< & a[i]) ;
}
for ( i=0 ; i<5 ; i++ )
sum = sum + a[i] ;
avg = sum / 5 ;
printf ("\n avg= %d", avg) ;
getch () ;
}


DRY RUN ;

sum =0 i=0 0<5
a[0] = 11
i=0 0<5 (TRUE)   i++ = 1
sum = sum + a[i]

similarly
for  i = 1,2,3,4  having true

for i = 5 ( 5<5 ) false

Tuesday, 19 June 2018

Program to calculate sum of an array of 5 element in C

/* sum of an array */
# include <stdio.h>
void main ()
{
int a[5] , i ;
int sum = 0 ;
clrscr () ;
for ( i=0 ; i<5 ; i++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a[i]) ;
}
for ( i=0 ; i<5 ; i++ )
sum = sum + a[i] ;
printf ("\n sum = %d", sum) ;
getch () ;
}


Monday, 18 June 2018

Program to find out the swap of two variable in C using function

/* swap of variables */
# include <stdio.h>
void swap (int , int) ;
void main ()
{
int a,b ;
clrscr () ;
printf ("\n Enter value of a:") ;
scanf ("%d", & a) ;
printf ("\n Enter value of b:") ;
scanf ("%d", & b) ;
swap (a,b) ;
getch () ;
}
void swap (int a , int b)
{
int temp ;
temp = a ;
a = b ;
b = temp ;
printf ("\n a = %d", a) ;
printf ("\n b = %d", b) ;
}


Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...