Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A character and number are given as input ally correct If the number is between 1 to 10 and character is between A to C then print ALPHA If the number is between 11 to 30 and character is between D to R then print BETA rked out of る Flag question If the number is between 1 to 10 and character is between D to R then print GAMMA If the number is between 11 to 30 and character is between A to C then print DELTA Otherwise print OMEGA For example: Input Result ALPHA SETA 30 R GAMMA 10 C DELTA 11 2 OMEGA 100 OMEGA

What I have tried:

C
#include<stdio.h> 
int main()
int a; char b; 
scanf("%d %c",&a,&b);
if((a=1 && ac-10 && b='A' &&bes'C'))
 printf("APLHA"); 
else if((a=11 && ac-30 && b='0' && b='R')) printf("BETA");
 else if((ax=1 && a<=10 && b='0' && b='R')) printf("GAMMA"): 
else if((a=11 48 ac30 && b='A' && b='C')) printf("DELTA"); 
else 
printf("OMEGA");
Posted
Updated 24-Dec-22 21:52pm
v3

In C, "=" is an assignment operator, not a comparison. To compare values, you need to us "==" instead:
C
if((a=1 && ac-10 && b='A' &&bes'C'))
Becomes:
C
if((a==1 && ac-10 && b=='A' &&bes'C'))
            ?????             ??????
Quite what you meant the bits with question marks below them to be is anyone's guess! Certainly, I have no idea ...

To check is a number is greater than another, use this: x >= y which is true if x is the same as or larger than y.
To check is a number is less than another, use this: x <= y which is true if x is the same as or less than y.
 
Share this answer
 
Comments
CPallini 23-Dec-22 13:30pm    
5.
Please start with some Learn C tutorial to write and understand the language. What you have written isnt good in anyway.
Take the advice from a seasoned coder: You will needs some hours to learn the basics or you will fail if you dont do it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900