Question

Rewrite the if statement below using only the relational operator < in all conditions

 53.  Rewrite the if statement below using only the relational operator < in all conditions. Assume that the value of score is between 0 and 100 inclusive.

image.png

 54.  Rewrite the following code segment as an equivalent segment that uses a do-while statement.

image.png

 55.  Assuming the following declaration:

 char my array[9] - ['C', 'p', 't', 'S', '9, '1', '2', '1']; 

What is the value of*(my array +4)?

3 0
Add a comment Improve this question Transcribed image text
Answer #1

//53.using < symbol only
#include
main()
{
   int score;
   printf("Enter score(0-100):");
   scanf("%d",&score);
   if(score<80)
       printf("C\n");
   else if(score<90)
       printf("B\n");
   else
       printf("A\n");
}

1 1/53. using < symbol only 2 #include<stdio.h> 3 main() 49 C 5 int score; 6 printf(Enter score(0-100):); 7 scanf(%d, &scEnter score (0-100):56 с

//54.using do while
#include
main()
{
   int sum=0,next=1,bound=10;
   do {
sum+=(++next);
}while(next printf("sum=%d",sum);

}

1 //54. using do whild 2 #include<stdio.h> 3 main() 49 { 5 int sum=0, next=1, bound=10; 6 do { 7 sum+=( ++next); 8 } while(nesum=54

//55.*(my_array+4) prints value of 4th index
#include
main()
{
   char my_array[9]={'c','p','t','s',' ','1','2','1'};
   printf("%c",*(my_array+4)); //here 4th index is space.so it prints space
}

1 //55. *(my_array+4) prints value of 4th index 2 #include<stdio.h> 3 main() 490 5 char my_array[9]={c,p, t, s, ,1Process exited after 1.287 seconds with return value 32 Press any key to continue .

Know the answer?
Add Answer to:
Rewrite the if statement below using only the relational operator < in all conditions
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Rewrite the if statement below using only the relational operator < in all conditions

     Rewrite the if statement below using only the relational operator < in all conditions. Assume that the value of score is between 0 and 100 inclusive. Rewrite the following code segment as an equivalent segment that uses a do-while statement. Assuming the following declaration: char my array[9] = ['C', 'p', 't', 'S', '', '1', '2', '1'); What is the value of *(myarray, + 4)? What will be the values of k[1], k[2], and k[3] after execution of the code segment below assuming the input data shown?

  • In C, write a program to convert a char (0-9) to Dec (ASCII value). Then convert...

    In C, write a program to convert a char (0-9) to Dec (ASCII value). Then convert an ASCII Value to char -------+ | ASCII CODE | + - ---+ +-- | char | Dec | ----+ | 'O' => 48 | | '1' => 49 | '2' => 50 | '3' => 51 | | '4' => 52 | | '5' => 53 | '6' => 54 | | '7' => 55 | | '8' => 56 | | '9'...

  • Fill the blank in each of the following using the terms at the bottom. IT. When...

    Fill the blank in each of the following using the terms at the bottom. IT. When an array is created, a value in the array is called a(n) 12. f and ) must always be used with an if) statement: True or False 13. Theoperator is used to check if two values are equal. 14. A command can only be used in a loop statement. 15. Acommand can be used in both a loop and switch statement. 16. In the...

  • In C++ Programming, Try using loops only. This lab demonstrates the use of the While Loop...

    In C++ Programming, Try using loops only. This lab demonstrates the use of the While Loop and the Do While Loop as error checking mechanisms. You will be using each of these loops to solve the same problem. Please put them both in the same program. When you test the code, you will not see a difference in the way they execute - but there will be a difference in the logic when writing the code. You will want to...

  • Rewrite the C++ code below so the the following conditions are met: You may create any...

    Rewrite the C++ code below so the the following conditions are met: You may create any number of classes. You may edit the main() function. Remove the variable string type completely from the entire program. -- Note: Entire program includes all classes, all functions, and main(). Get rid of every if and if else statement completely from the entire program. -- Note: Entire program includes all classes, all functions, and main(). Hint: Use polymorphism. #include <iostream> #include <vector> #include <algorithm>...

  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! myst...

    SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...

  • Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p;...

    Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...

  • _28. Using the following function prototype which statement about the argument passed to parameter Als true....

    _28. Using the following function prototype which statement about the argument passed to parameter Als true. void F(const int A[], int Cnt): A. The argument is modified when changes are made to parameter A in function F. B. The argument passed to parameter A must always have the same number of elements, every time function Fis invoked. C. Changes can not be made to parameter A in function F. D. Every element of the argument passed to parameter A must...

  • For 1 through 11, create an expression using the relational operators, the logical operators, and variable...

    For 1 through 11, create an expression using the relational operators, the logical operators, and variable names of your own choosing, no if or variable declaration is necessary. 1. is a person's age equal to 30? 2. is a body temperature greater than 98.6? 3. is a person's height less than 6 feet? 4. is the current month 12? 5. check if the letter input is m 6. is a person's age equal to 30 and is the person taller...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT