Chapter - 3: The Decision Control

Using conditional operators determine:


K
Sections
1
Exercises

A

B

C

D

E

F

G

H

I

J

K

1

2

3

(1) Whether the character entered through the keyboard is a lower case alphabet or not.

#include<stdio.h>
#include<conio.h>
int main()
{
	char chr;
	
	printf("Enter a character : ");
	scanf("%c", &chr);
	
	chr > 98 && chr < 123 ? printf("Lower case alphabet."):printf("Not a lower case alphabet.");
	
	getch();
	return 0;
}

(2) Whether a character entered through the keyboard is a special symbol or not.

#include<stdio.h>
#include<conio.h>

int main()
{
	char chr;
	
	printf("Enter a character : ");
	scanf("%c", &chr);
	
	chr < 123 && chr > 97 || chr > 64 && chr < 92 ? printf("Not a special symbol."):printf("Special symbol.");
	
	getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo