OBJECTIVE QUESTIONS.

Slides:



Advertisements
Similar presentations
Data Structures (Second Part) Lecture 2 : Pointers Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
Advertisements

Revision.
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
Tuesday, December 12, 2006 “Press any key to continue or any other key to quit.” - Anonymous.
#include using namespace std; void main() { int a[3]={10,11,23}; for(int i=0;i
If Statements. COMP104 If / Slide 2 Three Program Structures * Sequence - executable statements which the computer processes in the given order * Choice.
What is the out put #include using namespace std; void main() { int i; for(i=1;i
Functions Parameters & Variable Scope Chapter 6. 2 Overview  Using Function Arguments and Parameters  Differences between Value Parameters and Reference.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Functions Pass by Reference Alina Solovyova-Vincent Department of Computer Science & Engineering University of Nevada, Reno Fall 2005.
Chapter: 01 C++ Revision Tour
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
Array & Matrix Selected topics. 1. It will compare two adjacent elements, if second element is smaller than the first then it will swap them, if we wanted.
Statements
1 CS 101 Fall 2001 Lecture 3. 2 Boolean expressions The expressions that are allowed to be in the parentheses following an if can be of the form x>y,
April 11, 2005 More about Functions. 1.Is the following a function call or a function header? calcTotal(); 2.Is the following a function call or a function.
LESSON 4 Decision Control Structure. Decision Control Structures 1. if statement 2. if-else statement 3. If-else-if statement 4. nested if statement 5.
LESSON 3 Operators. Operators  Symbol that tells the computer to perform certain mathematical or logical manipulations.
Lecture 7 Computer Programming -1-. Conditional Statements 1- if Statement. 2- if ….. else Statement. 3- switch.
Mathematical Manipulation Data types Operator precedence Standard mathematical functions Worked examples.
Lesson xx Why use functions Program that needs a function Function header Function body Program rewritten using a function.
LESSON 5 Loop Control Structure. Loop Control Structure  Operation made over and over again.  Iterate statement.
T/F  The following code will compile without error. int x = 3, y = 4, z = 5; double k = 3.4; cout
User Defined Functions
C++ Lesson 1.
Pointers What is the data type of pointer variables?
Operator Overloading Ritika Sharma.
Chapter 3 Selection Statements
Fucntions in C++ Malik Jahan Khan
LESSON 2 Basic of C++.
Section 3 Review Mr. Crone.
LESSON 4 Decision Control Structure
Computing Fundamentals
Sorting Algorithms.
Enum ,Char Functions& Math Library Functions I.Mona Alshehri
לולאות קרן כליף.
Reserved Words.
User-defined Functions
Programming -2 برمجة -2 المحاضرة-5 Lecture-5.
Function User defined function is a code segment (block) that perform an specific action and may return a value. Function Definition: Return_DT F_name.
Random Number Generation
פונקציות לעיתים קרובות לא נוח להגדיר את כל התוכנה בתוך גוף אחד.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Compound Assignment Operators in C++
אבני היסוד של תוכנית ב- C++
מחרוזות-String בשפת C++ ישנו תפקיד מיוחד למערך מסוג char רצף של תווים הנמצאים במערך מסוג char המסתיימת בתו אפס (הכוונה לאפס ממש '0\' , ולא לתו '0')
User-defined Functions
Introduction to Programming
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
اصول کامپیوتر ۱ مبانی کامپیوتر و برنامه‌سازی
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Pass by Reference.
Summary Two basic concepts: variables and assignments Basic types:
Arrays Topics to cover: Arrays Data Types One-dimensional Arrays
If Statements.
Merge Sort.
Passing Arrays to functions
Programming fundamentals 2 Chapter 1: Functions (Sub-Algorithms)
CS 101 First Exam Review.
CS3369 Real Time Control Software/DENG Xiaotie
Pointers & Functions.
Branching statements Kingdom of Saudi Arabia
TOPIC: FUNCTION OVERLOADING
Introduction to Algorithms and Programming COMP151
Announcements Exam 2 Lecture Grades Posted on blackboard
Programming Fundamental
Programming Fundamental-1
Presentation transcript:

OBJECTIVE QUESTIONS

QUESTION:1 #include<iostream.h> #include<conio.h> main() { int x; for (x=1;x<=5;x++); cout<< x; getch(); }

QUESTION 2 #include<iostream.h> #include<conio.h> int main() { int x; for (x=1;x<=5;x++) cout<< x; cout<<++x; cout<< x++; getch();}

QUESTION :3 int fun(int a, int b) { if(a == 0) return 1; else if(b < a) return 0; else return fun(a-1, b-1) + fun(a-1, b); } main() int x = 3, y = 4; cout<< fun(x, y); getch();

QUESTION :4 #include<iostream.h> #include<conio.h> int main() { int *ptr1,**ptr2,***ptr3; int x; x=12; ptr1=&x; ptr2=&ptr1; ptr3=&ptr2; x=x+1; cout<<*ptr1<<**ptr2<<***ptr3; getch(); return 0; }

QUESTION:5 #include<iostream.h> #include<conio.h> main() { int i=1; if(i<5) cout<<i; i++; getch(); }

QUESTION 6: #include<conio.h> #include <iostream.h> enum xyz { a, b, c}; int main() { int x = a, y = b, z = c; int &p = x, &q = y, &r = z; p = z; p = ++q; q = ++p; z = ++q + p++; cout<< p << " " << q << " " << z; getch(); return 0; }

QUESTION:7 #include<iostream.h> #include<conio.h> int main() { int a[]={0,1,2,3,4,5,6,7,8,9,10}; int i=0,num; num=a[++i+a[++i]]+a[++i]; cout<<num; getch(); return 0; }

QUESTION:8 #include<iostream.h> #include<conio.h> union codeletter { int code; char letter; }c1; void printc1() cout<<"\n the code is:"<<c1.code; cout<<"\n the letter is:"<<c1.letter; } int main() c1.code=101; c1.letter='f'; printc1(); getch(); return 0;

QUESTION 9 #include<iostream.h> #include<conio.h> main() { void func(int,int=1,int=3,int=3); func(2,3); getch(); } void func(int x,int y,int z,int l) cout<<x+y+z+l;

QUESTION :10 #include<iostream.h> #include<conio.h> main() { int n=5, f=1; while(n>0) f*=n--; cout<<f; getch(); }

QUESTION :11 #include<iostream.h> #include<conio.h> void procedure(int,int,int); int main() { int x=10; procedure(x,x++,++x); getch(); return 0; } void procedure(int a,int b,int c) cout<<a<<"\t"<<b<<"\t"<<c;

QUESTION :12 #include<iostream.h> #include<conio.h> main() { int i=1; while(i<5) cout<<i; i++; getch(); }

QUESTION: 13 #include<iostream.h> #include<conio.h> main() { int i=100; for(int j=1; j<=4;j++) cout<<i<<j; getch(); }

QUESTION :14 #include<iostream.h> #include<conio.h> int test(int a,int b) { b+=5; a*=++b; return a; } int main() int x=5; x=test(x,x); cout<<x; getch(); return 0;}

QUESTION :15 #include<iostream.h> #include<conio.h> using namespace std; int main () { int firstvalue = 5, secondvalue = 15; int * p1, * p2; p1 = &firstvalue; p2 = &secondvalue; *p1 = 10; *p2=*p1; p2=p1; *p1=130; cout << "firstvalue is " << firstvalue<<endl; cout << "secondvalue is " << secondvalue << endl; cout<<*p1<<endl<<*p2; getch(); return 0; }

QUESTION 16 #include <iostream> #include<conio.h> using namespace std; int main () { int x=5,y; y=x++ + ++x +--x - x++; cout<<x<<y; getch(); return 0; }

QUESTION 17 #include<iostream.h> #include<conio.h> main() { int i=1; for(;i<5;i++); cout<<i++; getch(); }

QUESTION 18 #include<iostream.h> #include<conio.h> void print(int x); int main() { print(5); getch(); } void print(int x) if(x>0) print(--x); cout<<x;

QUESTION :19 #include<iostream.h> #include<conio.h> int main() { int a[4]={23,45,67,89,76}; int i; for(i=0;i<=4;i++) cout<<a[i]; getch(); }

QUESTION :20 #include<iostream.h> #include<conio.h> class x { private: int a,y; public: x() { a=12; y=2; } void show(x c) { cout<<c.a+c.y }}; int main() {x ob; ob.show(ob); getch(); }

QUESTION :21 #include<iostream.h> #include<conio.h> int main() { int a[5]={1,2,3,4,5}; cout<<*a++; getch(); }

QUESTION:22 #include<iostream.h> #include<conio.h> int main() { char a[]="hello"; char *p; p=a; cout<<*(++p); getch(); }

QUESTION :25 #include<iostream.h> #include<conio.h> class abc { public: float a;int x; abc() { cout<<"hello";} ~abc() {cout<<"destructor called"; } }; int main() { abc ob; cout<<sizeof(ob); getch();}

QUESTION:26 #include<iostream.h> #include<conio.h> class abc { public: int x,y; private: abc() { x=0; y=9; cout<<x<<y; } };int main() { abc ob; getch(); }

QUESTION :27 #include<iostream.h> #include<conio.h> int main() { int a[10],i,*p; for(i=0;i<=9;i++) cin>>a[i]; p=&a[0]; cout<<*(p+i+1); getch(); }

QUESTION :28 #include <iostream.h> #include<conio.h> void Values(int n1, int n2 = 10) { cout << "1st value: " << n1; cout << "2nd value: " << n2; } int main() { Values(1); Values(3, 4); getch(); return 0;

QUESTION :29 #include <iostream.h> #include<conio.h> int array1[] = {1200, 200, 2300, 1230, 1543}; int array2[] = {12, 14, 16, 18, 20}; int temp, result = 0; int main() { for (temp = 0; temp < 5; temp++) { result += array1[temp]; } for (temp = 0; temp < 4; temp++) { result += array2[temp]; cout << result; getch(); return 0;

QUESTION 30 #include <iostream.h> #include<conio.h> void func(int a, bool flag = true) { if (flag == true ) { cout << "Flag is true. a = " << a;}{ cout << "Flag is false. a = " << a; } } int main() func(2); cout<<"\n"; func(200, false); getch(); return 0; }