Quiz on C++ Data Types
To restrict what data can be stored in variables, data-type is used during declaration. Therefore, data types indicate what type of data a variable can store. When a variable is declared in C++, the compiler assigns memory based on its data type. The amount of memory needed for each data type varies.
Let’s take a quick quiz to see how well we understand data types in C++. Good Luck!
0 of 15 Questions completed Questions: You have already completed the quiz before. Hence you can not start it again. Quiz is loading… You must sign in or sign up to start the quiz. You must first complete the following: 0 of 15 Questions answered correctly Your time: Time has elapsed You have reached 0 of 0 point(s), (0) Earned Point(s): 0 of 0, (0) #include <iostream> using namespace std; int main() { int if = 98; int value; value = 100+if; cout<<“Value is “<<value; return 0; } #include <iostream> using namespace std; int main() { int data = “98”; int val=50; cout<<“After Adding value with val result is “<<data<<“+”<<val<<“we get”<<data+val; return 0; } What data type would be most appropriate for representing logical values? #include<iostream> using namespace std; int main() { cout << sizeof(char)<< ” byte” <<” &”; cout << sizeof(int)<< ” bytes” << endl; return 0; } #include<iostream> using namespace std; int main() { cout <<sizeof(short int)<< ” bytes” << ” & “; cout << sizeof(long int)<< ” bytes” << endl; return 0; } #include<iostream> using namespace std; int main() { cout << sizeof(float)<< ” bytes,” <<endl; cout << sizeof(double)<< ” bytes &” << endl; cout << sizeof(wchar_t)<< ” bytes” <<endl; return 0; } #include <iostream> using namespace std; int main() { int x ; int *ip; float a=0; cout << ” ” << sizeof(ip)<<“bytes”<<endl; cout << sizeof(a)<<“bytes”<< endl; return 0; } #include<iostream> using namespace std; int main() { int *ptr, data; data = 0; ptr = &data; cout<<*ptr; return 0; } #include<iostream> using namespace std; int main() { char c = 65; c = c+10; cout<<c; return 0; } #include<iostream> using namespace std; int main() { float x = 0.1; if ( x == 0.1 ) cout<<“Data”; else if (x == 0.1f) cout<<“QuizOrbit”; else cout<<“Quizzes”; } #include <iostream> using namespace std; int main() { typedef int number; number a = 30, b = 35; number c = 2*a + 2*b – 3*b – 2*a; cout << c; return 0; } Quiz Summary
Information
Results
Results
0 Essay(s) Pending (Possible Point(s): 0) Categories
1. Question
2. Question
3. Question
4. Question
5. Question
6. Question
7. Question
8. Question
9. Question
10. Question
11. Question
12. Question
13. Question
14. Question
15. Question
Summary
With the precious quiz of Data Types, you understood the core concepts of Data Types in C++. By taking this quiz, you have covered every Data Types concept in C++. We suggest you clear all your concepts before moving ahead. Happy Learning!
4 & 4 can also be the answer