EXP3
EXP3
DATE :
AIM :
To write a C program on swapping of two numbers using call by reference.
ALGORITHM :
SAMPLE OUTPUT :
RESULT :
Thus, the C program to perform swapping of two numbers using call by reference has
been executed successfully.
EX. NO - 3(B)
DATE : SWAPPING OF TWO NUMBERS UNING CALL BY VALUE
AIM :
To write a C program on swapping of two numbers using call by reference.
ALGORITHM :
#include <stdio.h>
void swap(int x, int y);
int main()
{
int a = 10, b = 20;
swap(a, b);
printf("a=%d b=%d\n", a, b);
return 0;
}
void swap(int x, int y)
{
int t;t
= x;x
= y;y
= t;
printf("x=%d y=%d\n", x, y);
}
SAMPLE OUTPUT :
x=20 y=10
a=10 b=20
RESULT :
Thus , we have implemented the c program swapping of two numbers using call by
value successfully .
EX. NO - 3(C)
DATE : STRUCTURE
AIM :
To write and implement a C program on structure.
ALGORITHM :
#include<st
dio.h>
#include<c
onio.h>
void
main()
{
struct stud
{
int
rno,m1,m2
; char
name[10];
};
struct
stud
s; int
tot;
float
avg;
clrsc
r();
printf("\n Enter the Student Name,Roll No,Mark1,Mark2
\n"); scanf("%s%d%d%d",s.name,&s.rno,&s.m1,&s.m2);
tot=s.m1+s.m2;
avg=tot/2;
printf("\n Student Name: %s, \n Student Roll no: %d \n Students Marks are
%d\t%d\
n",s.name,s.rno,s.m1,s.m2);
printf("\n Total Mark is ...%d\
n",tot); printf("\n Average is
%f\n",avg); getch();
}
SAMPLE OUTPUT :
Average is 97.000000
RESULT :