C Online Compiler
Example: C Program to Convert Celsius to Fahrenheit using Pointers
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Convert Celsius to Fahrenheit using Pointers #include <stdio.h> int main() { float c, f; float *ptr1, *ptr2; // c - To store the celsius // f - To store the fahrenheit printf("Enter the temperature in Celsius::\n"); scanf("%f", &c); // To get the address of `c` variable ptr1 = &c; // Conversion of celsius to fahrenheit f = ((*ptr1) * 9 / 5) + 32; // To get the address of `f` variable ptr2 = &f; // Final Output printf("\n%f Celsius = %f Fahrenheit\n", *ptr1, *ptr2); return 0; }
36
Output
Clear
ADVERTISEMENTS