Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C language and can’t use logical operators, relational, function calls or

ID: 3745298 • Letter: U

Question

Using C language and can’t use logical operators, relational, function calls or selection constructs can be used. Enter option 1 or 2 and then depending on options, ask to enter either "time" or "distance. Option 1 Enter "time" or Option 2 Enter "distance".

#include int main() {

int num; printf("Enter option 1 or 2: ");

scanf("%d", &num); printf(num == 1 ? "Enter time " : "Enter distance ");

return 0; }

In this coding above is "==" a logical/realtioinal operator? is there another whay with out using a relationoal/loigical operatror. I cant figure it out.

Explanation / Answer

You can use bitwise operator (bitwise AND) for this,

#include <stdio.h>
int main() {
int num;
printf("Enter option 1 or 2: ");

scanf("%d", &num);
printf(num &1 ? "Enter time " : "Enter distance ");

return 0; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote