-->
Showing posts with label program for division and multiplication of two numbers using pointer. Show all posts
Showing posts with label program for division and multiplication of two numbers using pointer. Show all posts

program for division and multiplication of two numbers using pointer

using codeblocks
------------------------------------------------------------------------
//division and multiplication of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
int main()
{
    float *p,*p1;                        //two pointer declaration
    float x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%f%f",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%f) is=%f\n",x,p);//display of that address
    printf("the address of y(%f) is=%f\n",y,p1);//display of address of second variable
    printf("the product=%f\n",(*p)*(*p1)); 
 //display of multiplication stored in that address. we display that using indirection operator

    printf("the quotient=%f",(*p)/(*p1));//display of quotient part
    return 0;
}
-------------------------------------------------------------------------------------------------------
using turboc++
-----------------------------------------------------------------------------------------------------
//division and multiplication of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
#include<conio.h>
int main()
{
    float *p,*p1;                        //two pointer declaration
    float x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%f%f",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%f) is=%f\n",x,p);//display of that address
    printf("the address of y(%f) is=%f\n",y,p1);//display of address of second variable
    printf("the product=%f\n",(*p)*(*p1));    
//display of multiplication stored in that address. we display that using indirection operator

    printf("the quotient=%f",(*p)/(*p1));//display of quotient part
   getch();
    return 0;
}