Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 8

#include <stdio.

h>
int main(void)
{
int a=10, b=20, c;
int *p, *q;
p=&a; q=&b;
c = *p + *q;
printf(" a= %d b = %d c = %d\n", a, b, c);
}

#include <stdio.h>
int main(void)
{

int a=10, b=20;


int *p, *q, *r, *s;
p=&a; q=&b;
r=p ; s =q;
printf(" a=%d b =%d c=%d d=%d\n", *p, *q, *r, *s);

#include <stdio.h>
void function1(int a, int b);
void function2(int *p, int *q);
int main(void)
{
int a=10, b=20;
function1 ( a, b);
printf("After Calling function1, a = %d b = %d \n", a, b);
function2 ( &a, &b );
printf("After Calling function2, a = %d b = %d \n", a, b);
}
void function1(int a, int b)
{
a = 0;
b = 0;

return; }

void function2(int *p, int *q)


{
*p = 0; *q = 0;

return; }

#include <stdio.h>
int main(void)
{
int array[]={10,20,30,40,50};
int count;
for(count=0; count<5; count++)
printf("\n Index=%d Address=%x Value = %d\n",
count,
&array[count], array[count]);
}

Index=0 Address=bfe42cb0 Value = 10


Index=1 Address=bfe42cb4 Value = 20
Index=2 Address=bfe42cb8 Value = 30
Index=3 Address=bfe42cbc Value = 40
Index=4 Address=bfe42cc0 Value = 50

#include <stdio.h>
int main(void)
{
int array[]={10,20,30,40,50};
int count;
for(count=0; count<5; count++)
printf("\nIndex= %d
count,
}

Address= %x
array+count,

Value=%d",
*(array+count));

void swap (char *p, char *q)


{
char tmp = *p;
*p = *q;
*q = tmp;
}
int lengthstr(char *s)
{
int length;
for (length=0; *(s+length) != '\0'; ++length);
return length;
}

void reverse(char *s)


{
char tmp, *end;
end = s + lengthstr(s) - 1 ;
while (s < end ) swap (s++, end--);
}
int main( void )
{
char string[80];
scanf( "%s", string);
reverse( string );
printf( "%s\n", string);
return 0;
}

You might also like