[Tutorial 7] 6.What output would you expect from the following program?

#include <stdio.h>
int main (void)
{
char c, d;
c = 'd';
d = c;
printf ("d = %c\n", d);
return 0;
}

Output:

d = d

Explanation:
- The character variable `c` is assigned the character `'d'`.
- Then, the value of `c` is assigned to the character variable `d`.
- Finally, the program prints the value of `d`, which is `'d'`.

Comments

Popular posts from this blog

[Tutorial 7] 10.Convert the given temperature in Celsius to Fahrenheit. T(°F) = T(°C) × 1.8 + 32

[Tutorial 7] 9.Calculate average marks of 4 subjects which, entered separately.

[Tutorial 7] 14.Write a program that converts inches to centimeters. For example, if the user enters 16.9 for a Length in inches, the output would be 42.926cm. (Hint: 1 inch = 2.54 centimeters.)