Question

Assume an array list is declared as follows: int list[100] and that all other variables have...

  1. Assume an array list is declared as follows:

int list[100]

and that all other variables have been appropriately declared. Tell whether each of the following is a valid or invalid statement. If not valid explain why not.

  1. cin>>list[3];

  1. cout<<list;
  1. x = list[3]+list[4];
  1. list[10] = 3.2;
  1. cout<<list[3, 5, 22];
  1. for (int i = 0; i < 100; i ++)

cout<<list[i];

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

a)  valid
b)  valid
c)  valid
d)  invalid. because we can not assign a double to an int
e)  invalid. because we can not give more than 1 value as index
f)  valid
Add a comment
Know the answer?
Add Answer to:
Assume an array list is declared as follows: int list[100] and that all other variables have...
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
  • Assume that you declare a variable as int x = 100 ; and correctly pass it...

    Assume that you declare a variable as int x = 100 ; and correctly pass it to a method with the declaration private static void IncreaseValue (ref int x) .There is a single statement within the IncreaseValue () method: x = x + 25 ; . Back in the Main ( ) method, after the method call, what is the value of x ? a The program will not run 125 O c. It is impossible to tell. O d...

  • Requirements: Finish all the functions which have been declared inside the hpp file. Details: st...

    Requirements: Finish all the functions which have been declared inside the hpp file. Details: string toString(void) const Return a visible list using '->' to show the linked relation which is a string like: 1->2->3->4->5->NULL void insert(int position, const int& data) Add an element at the given position: example0: 1->3->4->5->NULL instert(1, 2); 1->2->3->4->5->NULL example1: NULL insert(0, 1) 1->NULL void list::erase(int position) Erase the element at the given position 1->2->3->4->5->NULL erase(0) 2->3->4->5->NULL //main.cpp #include <iostream> #include <string> #include "SimpleList.hpp" using std::cin; using...

  • Consider the following statements: struct nameType { string first; string last; }; struct courseType { string...

    Consider the following statements: struct nameType { string first; string last; }; struct courseType { string name; int callNum; int credits; char grade; }; struct studentType { nameType name; double gpa; courseType course; }; studentType student; studentType classList[100]; courseType course; nameType name; Mark the following statements as valid or invalid. If a statement is invalid, explain why. student.course.callNum = "CSC230"; cin >> student.name; classList[0] = name; classList[1].gpa = 3.45; name = classList[15].name; student.name = name; cout << classList[10] << endl;...

  • C++ #include <iostream> using namespace std; bool checkinventoryid(int id) {    return id > 0; }...

    C++ #include <iostream> using namespace std; bool checkinventoryid(int id) {    return id > 0; } bool checkinventoryprice(float price) {    return price > 0; } void endProgram() {    system("pause");    exit(0); } void errorID(string str) {    cout << "Invalid Id!!! " << str << " should be greater than 0" << endl; } void errorPrice(string str) {    cout << "Invalid Price!!!" << str << " should be greater than 0" << endl; } int inputId() {...

  • Explain specifically what error. You may assume all includes are done properly, the code is inside...

    Explain specifically what error. You may assume all includes are done properly, the code is inside a valid function, assume "srand(time(0)):" has been set int x[5]; int sum; for(int 1-0 ; i <= 5; i++); x[i] sum = rand ( ) %100 ; x[i]; cout < "Sum is: "<<sum << endl;

  • There is a problem with thecode. I get the error messages " 'board' was not declared...

    There is a problem with thecode. I get the error messages " 'board' was not declared in this scope", \src\TicTacToe.cpp|7|error: expected unqualified-id before ')' token| \src\TicTacToe.cpp|100|error: expected declaration before '}' token| Here is the code #ifndef TICTACTOE_H #define TICTACTOE_H #include class TicTacToe { private: char board [3][3]; public: TicTacToe () {} void printBoard(); void computerTurn(char ch); bool playerTurn (char ch); char winVerify(); }; ************************************ TicTacToe.cpp #endif // TICTACTOE_H #include "TicTacToe.h" #include #include using namespace std; TicTacToe() { for(int i =...

  • Given a type Money that is a structured type with two int fields, dollars and cents. Assume that an array named monthlyS...

    Given a type Money that is a structured type with two int fields, dollars and cents. Assume that an array named monthlySales with 12 elements, each of type Money has been declared and initialized. Assume that a Money variable yearlySales has also been declared. Write the necessary code that traverses the monthlySales array and adds it all up and stores the resulting total in yearlySales. Be sure make sure that yearlySales ends up with a valid value, i.e. a value...

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

  • In C++ array. It should use an int numEvents' to keep track of how many events have been entered in the array. An event should be represented by a struct with several member variables. An event S...

    In C++ array. It should use an int numEvents' to keep track of how many events have been entered in the array. An event should be represented by a struct with several member variables. An event Strings for a name, description, and notes A date and time represented by their own structs. The Date struct should contain an int day, string month, and int year, and the Time struct should contain an int hour, int minute, int second, and bool...

  • PLEASE ANSWER ALL OF THEM, I REALLY APPRECIATE IT PLEASE IGNORE THE SELECTED ANSWERS Question 9...

    PLEASE ANSWER ALL OF THEM, I REALLY APPRECIATE IT PLEASE IGNORE THE SELECTED ANSWERS Question 9 3 pts Which best describes the meaning of a 1 (true) being output? Assume v is a large array of ints. int i; bool si for (i = 0; i < N_SIZE; Hi) { if (v[i] < 0) { S-true; else S = false; } cout << si O first value is negative all values are negative some value other than the last is...

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