Tomaso
Tomaso

Reputation: 15

Showing variables Printf

My question is that in the last statement I want to show the gc variable in the last printf. I mean: if you introduced 4 celsius, I want to show that 4 in the as well, but I dont know how to show an variable in a printf.

//celsius a radianes
#include<stdio.h>

int main(){

    float gc, gf = ( gc * 9 / 5) + 32;

    printf("\n Programa para convertir de Grados celsius a grados Fahrenheit\nIntroduzca un numero en grados celsius:\n");

    scanf("%f", &gc);
    gf = ( gc * 9 / 5) + 32;
    printf( "gc en Grados en fahrenheit = %.4f\n", gf); 
}

Upvotes: 0

Views: 80

Answers (1)

pmg
pmg

Reputation: 108988

Question edited heavily (sorry OP)

How to print gc and gf in print?

printf( "gc en Grados en fahrenheit = %.4f\n", gf);

Just add another %specifier and the corresponding variable

printf( "%.4f en Grados en fahrenheit = %.4f\n", gc, gf);
//       ^^^^ specifier1                ^^^^ specifier2

Upvotes: 2

Related Questions