Experimet:-25 Swapping The Values of Two Variables Using Call by Value

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

EXPERIMET:-25

Swapping the values of two variables using call by value


#include<stdio.h>
#include<conio.h>
void swap(int,int); int
main()
{
int a=10;
int b=20;
printf("Before swapping the values in main a =%d,b=%d\n",a,b);
swap(a,b);
printf("After swapping values in main a=%d,b=%d\n",a,b);
}
void swap(int a,int b)
{
int temp;
temp=a; a=b
b=temp;
printf("After the swaping vlaues in function a=%d,b=%d\n",a,b); getch();
}

Prashant Sharma(CSE 1ST SEM) PAGE NO:-31


EXPERIMENT:-26
Swapping the values of two variables using call by reference
#include<stdio.h>
#include<conio.h>
void swap(int*,int*);
int main()
{
int a=10;
int b=20;
printf("Before swapping the values in main a =%d,b=%d\n",a,b);
swap(&a,&b);
printf("After swapping values in main a=%d,b=%d\n",a,b);
}
void swap(int*a,int*b)
{
int temp;
temp=*a;
*a=*b; *b=temp;
printf("After the swaping vlaues in function a=%d,b=%d\n",*a,*b);
getch();
}

Prashant Sharma(CSE 1ST SEM) PAGE NO:-32


INDEX
S.NO PROGRAME REMARK
1 .WAP to print “Hello world”

2 WAP to add two numbers

3 WAP to perform addition,multiply,substraction and divison

4 WAP to calculate area of rectangle

5 WAP to calculate area and circumference of circle

6 WAP to cal volume of cubide having height = 10cm ,


width=12cm and depth=8cm

7 WAP to calculate simple interest

8 .WAP to swap two numbers with and without using third


variable. *WITH USING THIRD VARIABLE*

9 .WAP to swap two numbers with and without using third


variable. *WITHOUT USING THIRD VARIABLE*

10 WAP to display the size of every data type using “sizeof”


operator

11 WAP to find the root of a quadric equation

12 WAP to print given number is even using if statement

13 WAP to print given number is even or odd using if..else


Statement.

14 WAP to check greatest number among three numbers using


nested if-else statement.

15 WAP to check whether the given number is divided by 5,8 or


both using If..else If ladder.

16 WAP to print days of week by using switch statement.

17 WAP to print the table of 1 by using do-while loop.

18 Program to print table for the given number using do while


loop.
19 WAP program of while loop that prints table of 1.

20 Program to print table of given number using while loop in c.

21 WAP of for loop that prints table of 1.

22 WAP Print table for the given number using C for loop.

23 WAP /* printing the pattern.

WAP C program tp find the sum of two matrixes of order 2*2


24 Two dimensional Array

25 Swapping the values of two variables using call by value

26 Swapping the values of two variables using call by


reference

You might also like