1) Assume that x is a char variable has been declared and already given a value
ID: 3538564 • Letter: 1
Question
1) Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is alphanumeric , that is either a letter or a decimal digit.
2) Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a letter.
3) Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is a letter.
4)
Explanation / Answer
//
// main.cpp
// Chegg
//
// Created by Satya Prakash on 02/07/13.
// Copyright (c) 2013 Satya Prakash. All rights reserved.
//
#include <iostream>
#include <math.h>
#include <cmath>
using namespace std;
int main(int argc, const char * argv[])
{
char var;
bool exp1,exp2,exp3;
cout<<"Enter an character "<<endl;
cin>>var;
if ((48 <=var && var<=57) || (var>=65 && var<=90) || (var>=97 && var<=122)) {
exp1=true;
cout <<"inpur character is alphanumaric "<<endl;
}
if (!((var>=65 && var<=90) || (var>=97 && var<=122))) {
exp2=true;
cout <<"inpur character is not a letter "<<endl;
}
if (((var>=65 && var<=90) || (var>=97 && var<=122))) {
exp3=true;
cout <<"inpur character is a letter "<<endl;
}
// exp1 =((48 <=var && var<=57) || (var>=65 && var<=90) || (var>=97 && var<=122))
// exp2 =(!((var>=65 && var<=90) || (var>=97 && var<=122)))
// exp3 = (((var>=65 && var<=90) || (var>=97 && var<=122)))
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.