Professional Documents
Culture Documents
#include<stdio.h>
main()
{
FILE *f1;
char c;
/*printf("\nData input\n");
f1=fopen("Input","a");
while((c=getchar())!=EOF)
putc(c,f1);
fclose(f1);
printf("\nData output\n");
f1=fopen("INPUT","r");
while((c=getc(f1))!=EOF)
printf("%c",c);
fclose(f1); */
printf("\nData input\n");
f1=fopen("Input","a");
while((c=getchar())!=EOF)
putc(c,f1);
fclose(f1);
printf("\nData output\n");
f1=fopen("INPUT","r");
while((c=getc(f1))!=EOF)
printf("%c",c);
fclose(f1);
system("pause");
}
f2=fopen("EVEN","r");
f3=fopen("ODD","r");
printf("\nContents of f2\n");
while((num=getw(f2))!=EOF)
printf("\n%d",num);
printf("\nContents of f3\n");
while((num=getw(f3))!=EOF)
printf("\n%d",num);
fclose(f2);
fclose(f3);
system("pause");
}
main()
{
int x=10,y=5,*p1=&x,*p2=&y;
float res;
//p1=&x;
//p2=&y;
res=(float)*p1/ *p2;
printf("Address of x=%u\n",&x);
printf("Address of y=%u\n",&y);
printf("Address of p1=%u\n",&p1);
printf("Address of p2=%u\n",&p2);
printf("Address of res=%u\n",&res);
printf("value of x =%d\n",x);
printf("value of y =%d\n",y);
printf("value of p1 =%d\n",*p1);
printf("value of p2 =%d\n",*p2);
printf("value of res =%f\n",res);
system("pause");
}
//Swap using pointers
main()
{
int temp,*a,*b,x,y;
scanf("%d%d",&x,&y);
a=&x;
b=&y;
temp=*a;
*a=*b;
*b=temp;
printf("*a=%d\t*b=%d\n",*a,*b);
printf("x=%d\ty=%d",x,y);
system("pause");
}