Knowee
Questions
Features
Study Tools

VariablesIf char c = -'a', find output of the statement,printf("%d", c);Options-97-aCompilation Error-6565

Question

VariablesIf char c = -'a', find output of the statement,printf("%d", c);Options-97-aCompilation Error-6565

🧐 Not the exact question you are looking for?Go ask a question

Solution

The answer is "Compilation Error".

Here's why:

In C programming, a character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself. This integer value is the ASCII code of the character.

For example, the ASCII value of 'a' is 97. So, if you assign 'a' to a char variable, 97 is stored, not 'a' itself.

However, in your case, you're trying to assign -'a' to a char variable. The unary minus operator is trying to negate an unsigned value, which is not allowed, hence it will cause a compilation error.

This problem has been solved

Similar Questions

What will be the output of the following program?print(char(97))Options'A''a'NameError: name 'char' is not defineda

What will be the output of the following C program?#include<stdio.h>int main(){char c;c = 'A';printf("%c",c);return 0;}Select one:65Aac

Select the correct answerAnalyse the code and choose the right option.#include <stdio.h>int main(){  extern int A;  printf("%d",A);  return 0;}A=550;OptionsThe code will print 0The code will print 550The code will give error undefined reference to variable A.The code will print garbage value

VariablesWhat will be the status of this program upon compilation?#include <stdio.h>int main() {  char j = 'a';  int i = j;  int k = (int)j;  int l = 75;  char m = (char)l;  printf("value of i = %d, k = %d\n", i, k);   printf("value of l = %d, m = %c\n", l, m);   getchar();  return 0;}OptionsError in compilationvalue of i = 97, k = 97value of l = 75, m = KNo Outputvalue of i = 'a', k = 97value of l = 75, m = '7

Select the correct output for the below C code?#include <stdio.h>void main() { int a = 0; { int a = 10; printf("%d",a); a++; { a = 20; } { printf(" %d",a); int a = 30; { a++; } printf(" %d",a++); } printf(" %d",a++); } printf(" %d",a);}Options10 11 30 11 010 20 31 20 010 20 30 20 0Compilation error

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.