0% found this document useful (0 votes)
5 views

PBM Pointers

Pointers

Uploaded by

Vilasini Rajesh
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PBM Pointers

Pointers

Uploaded by

Vilasini Rajesh
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>

int main()
{
char alph[27];
int x;
char *ptr;
printf("\n\n Pointer : Print all the alphabets:\n");
printf("----------------------------------------\n");
ptr = alph;

for(x=0;x<26;x++)
{
*ptr=x+'A';
ptr++;
}
ptr = alph;

printf(" The Alphabets are : \n");


for(x=0;x<26;x++)
{
printf(" %c ", *ptr);
ptr++;
}
printf("\n\n");
return(0);
}

-----------------------------------------------------
#include <stdio.h>
int main()
{
char str1[50];
char revstr[50];
char *stptr = str1;
char *rvptr = revstr;
int i=-1;
printf("\n\n Pointer : Print a string in reverse order :\n");
printf("------------------------------------------------\n");
printf(" Input a string : ");
scanf("%s",str1);
while(*stptr)
{
stptr++;
i++;
}
while(i>=0)
{
stptr--;
*rvptr = *stptr;
rvptr++;
--i;
}
*rvptr='\0';
printf(" Reverse of the string is : %s\n\n",revstr);
return 0;
}

You might also like