#include<stdio.h> void change(int a) { a++; } void main() { int a=5; printf("\n%d",a); change(a); printf("\n%d",a); }
5 5
#include<stdio.h> void change(int *p) { (*p)++; } void main() { int a=5; printf("\n%d",a); change(&a); printf("\n%d",a); }
5 6
#include<stdio.h> void swap(int *p,int *q) { int temp; temp=*p; *p=*q; *q=temp; } void main() { int a=5,b=7; printf("\nA=%d B=%d",a,b); swap(&a,&b); printf("\nA=%d B=%d",a,b); }
A=5 B=7 A=7 B=5
#include<stdio.h> void Circle(int r,float *p,float *q) { *p=3.14*r*r; *q=2*3.14*r; } void main() { float a,c; Circle(1,&a,&c); printf("Area is %f \n Circcumference is %f",a,c); }
Area is 3.140000 Circcumference is 6.280000
#include<stdio.h> void rectangle(int l,int b,int *p,int *q) { *p=l*b; *q=2*(l+b); } void main() { int a,p; rectangle(5,10,&a,&p); printf("Area is %d \nPerimeter is %d",a,p); }
Area is 50 Perimeter is 30