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
Write a program factor that prints the prime factors of a specified non-negative integer. The integer...
Write a program factor that prints the prime factors of a specified non-negative integer. The integer will be provided as a command-line argument. You may assume that the integer will be greater than 1 and less than or equal to the largest signed integer on your platform (that is, you may use an int).
Write a C++ program to find least common multiple (LCM) of two, three and four integer...
Write a C++ program to find least common multiple (LCM) of two, three and four integer values. The integer values are entered from the keyboard and the outputs are printed to the console. The LCM of two, three and four integer values are computed using Prime factorization method. You have to use arrays to hold input values and use functions/methods to get data from the keyboard, display output to the console, calculate LCM using Prime factorization method. Your program should...
Write a C++ program to find least common multiple (LCM) of two, three and four integer...
Write a C++ program to find least common multiple (LCM) of two, three and four integer values. The integer values are entered from the keyboard and the outputs are printed to the console. The LCM of two, three and four integer values are computed using Prime factorization method. You have to use arrays to hold input values and use functions/methods to get data from the keyboard, display output to the console, calculate LCM using Prime factorization method. Your program should...
Write a C program called test that takes one command line argument, an integer N. When...
Write a C program called test that takes one command line argument, an integer N. When we run test: ./test N the program will do this: the parent process forks N child processes each child process prints its process ID, exits the parent process waits for all child processes to exit, then exits
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....
Let a , b , c be three integer numbers. Write a C++ program with a...
Let a , b , c be three integer numbers. Write a C++ program with a functions void rotate1(int* a,int* b,int* c) void rotate2(int& a,int& b,int& c) such that a -> b , b -> c and c -> a. Thus we use two different approaches (pointers in rotate1 and references in rotate2).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT