Write a program to print logic 1 if input charcter is capital otherwise 0.

#include<stdio.h>
#include<conio.h>
int main()
{
	char x;
	int y;
	printf("\n Enter a character:");
	scanf("%c",&x);
	y=(x>=65 && x<=90 ? 1 : 0);
	printf("y :%d",y);
	getch();
}

/*Above program a charcter is entered.using logical operator AND entered character's ASCII value is 
checked.If it is in between 65 to 90,the result displayed will be 1 otherwise 0.*/

The above program takes a character as input from the user and stores it in the variable x. The value of y is then evaluated using a conditional operator that checks if the ASCII value of x is between 65 and 90 (the range of uppercase letters in the ASCII table). If it is, y will be assigned the value 1, otherwise, it will be assigned the value 0. Finally, the value of y is displayed on the screen.

Thanks

Write a program to print logic 1 if input charcter is capital otherwise 0.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top