CGS3406 Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What will be the probable argument syntax for this add function where the function body is written? { int z =a+ b +c; return z; } Hint: The syntax is not the same as the calling function scope. - (int a, int b, int c) - () - (a, b, c) - (a ; b ; c)

(int a, int b, int c)

int i = 0; i--; What is the value of I? - 0 - 1 - 2 - -1

-1

What should be the value of ((50 + 50) / 10 -(2 * 10))? - 30 - -10 - 90 - 35

-10

What is the output of the following? (3 times 6- 4 / 2 times 100) - not a valid number - -182 - 17.98 - error

-182

Which of these extensions your file should have if you are writing a C++ code in it? - .txt - .py - .cpp - .docx

.cpp

Which characters should you use to write a Comment inside your code? - % - / - ; - //

//

int i =1; if (i>3) std::cout<<i+1; elseif (i<2) std::cout<<i; else std::cout<<i+2; What is the output? - 0 - 3 - 2 - 1

1

int i =0; do { i++;std::cout<<i<<endl; } while(i<5); What should be the output? - 1,2,3,4,5 - 0,1,2,3,4,5 - 1,2,3,4 - 0,1,2,3,4

1,2,3,4,5

Which of these languages can the computer hardware understand easily? - Put 100 inside i (int) - 1001 1010 - Add $R1, $R2, $R3 - int i = 100

1001 1010

#define MAXSTUDENTS 100 int main() { int i = MAXSTUDENTS ; i++; std::cout<<i<<" "; std::cout<<MAXSTUDENTS ; return 0; } What is the most probable output? - 100, 101 - 100, 100 - 101, 101 - 101, 100

101, 100

x has a value of 50. What will be the value of x after this statement executes? x *= 3; - 47 - 150 - 53 - 50

150

int i =1; if (i==1) std::cout<<i+1; elseif (i==2) std::cout<<i; else std::cout<<i+2; What is the output? - 2 - 3 - 0 - 1

2

int a = 10; int b = 20; What should be the output of (a>b)?a:b - 10 - 0 - 1 - 20

20

a = 200; b = 50; c = 90; d = 50; - a= b+ a; c = b+d; d++; What will be the values of a,b,c,d? - 250, 50, 90, 50 - 200, 200, 90, 51 - 200, 190, 50, 50 - 250, 50, 100, 51

250, 50, 100, 51

int numbers[20]={1,2,3,4,5}; what is the value of numbers[2] ? - 2 - 3 - 4 - 1

3

What should be the value of (50 + 50 / 10 -2 * 10) ? - -10 - 30 - 35 - 90

35

#include<iostream> int a = 10; int z =5; int main () { int a = 5; std::cout<< a; return 0; } What should be the most probable output of this? - 10 - 0 - none of these - 5

5

For using strcpy which header file should we include? - <stdio.h> - <iostream> - <string> - <cstring>

<cstring>

char words[20][20]={"APPLE","ORANGE","COFFEE"}; int i; for(i=0;i<3;i++) std::cout<<word[i][0]; what should be the output? - COF - APP - APPLE - AOC

AOC

char words[20][20]={"APPLE","ORANGE","COFFEE"}; int i; for(i=0;i<3;i++) std::cout<<word[i][i]; what should be the output? - ORA - ARF - AOC - APP

ARF

When a ".o" file is obtained? - After linking - After compilation - Before Linking - Before compilation

After compilation, before linking

What type of operator is this? = - Assignment - Unary - Addition - Comparative

Assignment

When should you start designing an algorithm? - While coding - After coding - Before coding - After project compilation

Before coding

What is the smallest addressable unit of storage in a computer? - Bit - MB (Megabytes) - KB (Kilobytes) - Byte

Byte

char words[20]={'C','A','T','S'}; what is the value of words[0]? - C - ATS - S - CATS

C

In what stage does syntax checking happen for a C++ program? - Linking - Create source code - Compilation - Preprocessing

Compilation

What type of datatype is an array? - User-defined - Primary - None - Derived

Derived

You have a number 9.98. In which datatype will you store this? - Double - Char - String - Int

Double

Any legal C++ program is a legal C program. (T/F)

False

Which of these is not a primary datatype in C++? - Function - Character - Integer - Boolean

Function

Which of these is not an output device? - Hard disk - Screen/console - Network card - Headphones

Hard disk

Which of these stages in software development is mostly associated with writing codes? - Analysis and Problem Definition - Testing - Design - Implementation

Implementation

What is the purpose of #include in C++ code? - initializing the compiler - including a file into your code - control the body of the main function - controls when the program ends

Including a file into your code

int i = 0; while(i<5) { if(i<2) continue; std::cout<<i; } What should be the output of this part? - 3,4,5 - infinite loop - 1,2 - 0,1,2,3,4 - i++;

Infinite loop

Which of the following return type should main have? - char - std::string - Int - void

Int

Which header file do we need to include in our C++ code to use cout and cin? - namespace std - Stdio.h - Printer.h - Iostream - #include<iostream>

Iostream

From which function does the execution of a C++ program start? - Main.cpp - printer.h - Printer - Main

Main

char words[20][20]={"APPLE","ORANGE","COFFEE"}; what is the value of words[1][3]? - L - N - P - A

N

int i = 0; while(i==8) { std::cout<<i; i++; } - 0,1,2,3,4,5,6,7,8 - No output - 1,2,3,4,5,6,7,8 - 0,1,2,3,4,5,6,7

No output

char message[10] = "HelloWorld"; message[4] = ? What are the characters in the character array? - HelloWorld - Hello - l - O

O

C++ is what type of language? - High-Level Procedural - Assembly - Object-Oriented - Machine

Object-Oriented

In which of these memories, will be your data that is currently being worked on? Hint: This place also stores executing programs - Pen drive - CPU - DVD - RAM

RAM

Which of these is not an input device? - Keyboard - Scanner - RAM - Mouse

RAM

What statement ends a function? - Break - Cout - exit - Return

Return

What type of error is this? { int a; std:cout<<a; } Semantic or syntax

Semantic

Which of these is not a technique for formulating an algorithm? - Semantics - Flowcharts - Pseudocode - Top-down refinement

Semantics

In C++ code, there is an initialization: mytext = "Hello World"; What should be the datatype of myText variable? - Int - Char - String - Double

String

What type of error will this be? { int a; a= 100; std::cout<<;a; } Semantic or syntax

Syntax

We have: int i; char c; Is i=c; legal? (T/F)

True, i is smaller than c

Inside a function we have { int z = a+b+c; return; } What is the return type of this function? - Bool - Int - Void - Char

Void

using namespace std; int main () { int a = 10; if (a==10) cout<< "a is 10"; else cout<<"a is not 10 yet"; return 0; } What is the output? - a is 10 - a is not initialized, so there will be an error - a is not 10 yet - 0

a is 10

#include<iostream> int a = 10; int z = 5; int main () { int b = 10; int c = 12; return 0; } Which of these is a global variable? - none of these - b - a -z - c

a-z

You have a list of grocery items to store. In which datatype will you store them? - char array - double array - float - int array

char array

We have data that looks like this: "AD-1256239" In which datatype will you store this? - double - int - character - character array

character array

Which of these will take input from the user and puts it inside "name" variable; ? - cout<<name; - cin>>name; - cout>>name; - cin<<name;

cin>>name;

What is the use of "\n"? - tab - none - end line - space

end line

const int SIZE = 10; int main(){ SIZE = 20; std::cout<<SIZE; return 0; } What is the most probable output? - 10 - error: SIZE is not declared in this scope - error: SIZE is a read only variable - 20

error: SIZE is a read only variable

What type of a return statement should a function having char return type have? - return 0; - return; - return 'x'; - return 1;

return 'x';

Which of these will you use to print to the screen? - std::cin<< - std::cout<< - std::cout>> - std::cin>>

std::cout<<

int add(int,int,int); is a prototype of a function. Based on this fill in the blanks: int main() { int x ,y ,z; //we are just sending these to add function. x = 10; y = 20; z = 30; add(_______???????________); return 0; } - int x , int y , int z ~ No need to give datatype because they are already declared in this scope. - string x, string y, string z - std::string x, std::string y, std::string z - x,y,z

x,y,z


Ensembles d'études connexes

BIO Chapter 5 Practice - Tommy Minar

View Set

Valence Electrons and Lewis Dot Diagrams*

View Set

Employment Law - Disability discrimination

View Set

OST-249 - Chapter 12 - Evaluation and Management

View Set

Job-Order Costing: Cost Flows and External Reporting Chapter 3

View Set

Soil Exam 1 Version 1 2017 Spring Test (Cox) MSU

View Set

Kolonialisme dan imperialisme:-)

View Set

A Closer Look: Parallel Structure

View Set