Question

In: Computer Science

write a c++ program an expression that determines if an integer, n is a negative four...

write a c++ program an expression that determines if an integer, n is a negative four digit number.

write a c++ program an expression that determines if a string, wd, equals "so" ignoring case.

Solutions

Expert Solution

Here are the answers for your questions in C++ Programming Language.

Kindly upvote if you find the answer helpful.

#########################################################

CODE :

Question : write a c++ program an expression that determines if an integer, n is a negative four digit number.

#include<iostream>

using namespace std;

int main(){
   //Required variable
   int n;
  
   //Read value from user(assuming user eners valid value)
   cout << "Enter an integer: ";
   cin >> n;
  
   //Expression to determine if 'n' is a negaive four digit number
   if(n >= -9999 && n <= -1000){
       cout << "Given integer " << n << " is a negative four digit number." << endl;
   }else{
       cout << "Given integer " << n << " is NOT a negative four digit number." << endl;
   }
   return 0;
}

##############################################################

SCREENSHOTS :

Please see the screenshots of the code below for the indentations of the code.

##########################################################################

OUTPUT :

#########################################################################

CODE :

Question : write a c++ program an expression that determines if a string, wd, equals "so" ignoring case.

#include<iostream>
#include<strings.h>

using namespace std;

int main(){
   //Required variable
   string wd;
  
   //Reading input from user
   cout << "Enter a string: ";
   cin >> wd;
  
   //Expression to determise the string wd equals 'so' ignoring case
   if(strcasecmp(wd.c_str(),"so")== 0){
       cout << "Given string equals 'so'." << endl;
   }else{
       cout << "Given string doesn't equal 'so'." << endl;
   }
   return 0;
}

####################################################################

SCREENSHOTS :

Please see the screenshots of the code below for the indentations of the code.

########################################################################

OUTPUT :

Any doubts regarding this can be explained with pleasure :)


Related Solutions

Write a C++ program that randomly generates N integer numbers (such that N is entered by...
Write a C++ program that randomly generates N integer numbers (such that N is entered by the user) and then stores them to a text file (myNumbers.txt) sorted in increasing (non-decreasing) order. Again, please notice that the size of the data (N) is known during the run time, not the compile-time (needs to be entered by the user after running the program).
Write a program in C or in Java, that takes an integer value N from the...
Write a program in C or in Java, that takes an integer value N from the command line, generates N random points in the unit square, and computes the distance separating the closest pair of points. A unit square is a square with sides of length 1, at points (0, 0), (0, 1), (1, 0), and (1, 1). If you wish to avoid the command-line processing, you can just assume you will generate a fixed number of points, say between...
In C++ Let n be a non-negative integer. The factorial of n, written n!, is defined...
In C++ Let n be a non-negative integer. The factorial of n, written n!, is defined by 0 ! 5 1, n! = 1·2·3· · ·n if n $ 1. For example, 4! = 1·2·3·4 = 24. Write a program that prompts the user to enter a nonnegative integer and outputs the factorial of the number. Allow the user to repeat the program. Example: If the user enters a 3 then your program should perform answer = 3 * 2...
Write a c++ program of the Fibonacci Sequence. Have the user enter a positive integer n...
Write a c++ program of the Fibonacci Sequence. Have the user enter a positive integer n and compute the nth Fibonacci number. The program should end when the user enters a number less than or equal to zero
ite a C program that prompts for and reads in a non-negative integer from the keyboard....
ite a C program that prompts for and reads in a non-negative integer from the keyboard. Read it into an int variable x. Then display the 32 bits in x from the lsb to the msb (so the display will show the value in x in binary with the bits in reverse order). For example, if you input 6, then your program displays 00000000000000000000000000000110 Use the algorithm given in class (repeatedly divide by 2). Use the / and % operators....
PYTHON Let n denote an integer entered by the user. Write a program to print n...
PYTHON Let n denote an integer entered by the user. Write a program to print n multiples of 5 in the descending order, with the last number being 5. Print the average of those n multiples
In c++ Write a program that reads a string consisting of a positive integer or a...
In c++ Write a program that reads a string consisting of a positive integer or a positive decimal number and converts the number to the numeric format. If the string consists of a decimal number, the program must use a stack to convert the decimal number to the numeric format. Use the STL stack
a). Write a program that asks the user to enter an integer N and prints two...
a). Write a program that asks the user to enter an integer N and prints two integers, root and power, such that 1 < power < 6 and N = root ** power. If no such pair of integers exists, it should print a message to that effect. There are two loops, one for power and one for root. Order the loops so that if N = 64, then your program find that N = 8 ** 2 rather than...
In Python, write a program to get a positive integer n from keyboard first (your program...
In Python, write a program to get a positive integer n from keyboard first (your program must be able to check the validation of n being positive), and then get n integers from keyboard and store these n integers in a list. Do some processing, and print out average of the elements in the list at end of your program. For example, suppose user enters 3 first (n = 3), which means we get another three integers from the user....
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT