To declare the user defined string & to display it using pointers

#include<stdio.h>
main()
{
    char str[100],*p,*q,i,j;
    printf("Enter the string\n");
    gets(str);
    p=&str;
    j=strlen(str);
    printf("The entered string is ");
    for(i=0;i<j;i++)
    {
        printf("%c",*(p+i));
    }

}

 

 

OUTPUT:

Enter the string

bloggingsimplified

The entered string is bloggingsimplified

Download the program:

To declare the user defined string & to display it using pointers

Performing arithmetic operations using pointers.

#include<stdio.h>
#include<string.h>
main()
{
int y,x;
printf("Enter x and y to perform arithmetic operations on it.\n");
scanf("%d",&x);
scanf("%d",&y);
int *p,*q;
p=&x;
q=&y;
int a,b,c,d;
a=(*p+*q);
b=(*p)-(*q);
c=(*q)*(*p);
d=(*p)/(*q);
printf("Addition=%d Subtraction=%d Multipication=%d Divide=%d",a,b,c,d);

}

 

 

Output [Click to enlarge]:

Arithmetic