IT22111 Record - 96 (Ex9)
IT22111 Record - 96 (Ex9)
EX.NO: 9.1
DATE:
QUESTION:
Demonstrate address of (*) and indirection (*) operators. Write a C program, to swap two
number using pointers.
AIM:
To write a C program to swap two numbers using pointers.
PSEUDO CODE:
#include<stdio.h>
int swapping(int*,int*);
int main()
{
int x,y;
printf("Enter value of x:");
scanf("%d",&x);
printf("Enter value of y:");
scanf("%d",&y);
printf("\nx & y before swapping %d & %d", x, y);
swapping(&x,&y);
printf("\nx & y after swapping %d & %d\n", x, y);
return 0;
}
SAMPLE OUTPUT:
RESULT:
The C program swaps two numbers using pointers and displays them successfully.
EX.NO: 9.2
DATE:
QUESTION:
AIM:
To write a C program for a pocket calculator with arithmetic operators using pointers.
PSEUDO CODE:
#include<stdio.h>
int add(int*a,int*b)
{
return *a + *b;
}
int sub(int*a,int*b)
{
return *a - *b;
}
int multi(int*a,int*b)
{
return *a * *b;
}
int div(int*a,int*b)
{
int main()
{
int a,b,ch;
printf("Enter the first number:");
scanf("%d",&a);
printf("Enter the second number:");
scanf("%d",&b);
printf("--calculator operation--");
printf("\n1.Addion\n2.Subtraction\n3.Multiplication\n4.Division\n5.Modulus\n6.Increment\
n7.Decrement");
printf("\nEnter your choice:");
scanf("%d",&ch);
switch (ch)
{
case 1:
SAMPLE OUTPUT:
RESULT:
The C program implements a pocket calculator with arithmetic operators using pointers
and displays the answer successfully.