Skip to content

AbhishekBhatt072003/OOPs-with-Cpp

Repository files navigation

OOPs With C++

Name - Abhishek Bhatt
Sec - C
Student ID - 200111138

Practical 3

Task1: How the preprocessor will react when you try to use, #include<iostream.h> instead of #include?

Task2: How the preprocessor will react when you use cout but don't include #include in your code?

Task3: Take a char variable and use cin to take its value from the user, cout it and it will only return one character and loss rest of the data you have entered!

Task4: How to resolve above issue? [Hint: by using, getline(cin, line);]

Practical 4

add(int,int), add(float, float), both of these methods are in two different namespaces First and Second respectively.

Task1: Access these methods using scope resolution operator :: from main method?

Task2: Access these methods using "using" keyword for main method?

Task3: Try to access these methods without using, (SRO) and "using" keyword and check how the compiler will react to it?

Task4: Try to access these methods for Mixed Values [Int, Float] and see how the compiler will react to it?

Practical 5

Primary Data Types related questions in C++:

Task1: Initialise all primary data types, assign their values and print them all? [char, bool, short, int, long, float, double, long double, wide char]

Practical 6

String related Questions in C++:

Task1: What happens if we add integer with a string, how the compiler would react to it?

Task2: Check the entered string is Palindrome or not?

Task3: Make a reverse of a string using reverse method and reverse_iterator of string class?

Task4: String Compare: Check if the strings are equal or not? (do not use str1.compare(str2), do it manually)

Task5: String Compare: Check the possible values string.compare() function will return?

Task6: Check if string is mutable in C++ or not?



Practical 7


Array and 2D Array related Questions in C++:

Task-7.1 Create a switch statement [Manual], In Which:

a. When you pass 1 your program would print current year b. When you pass 2 your program would print current month c. When you pass 3 your program would print current day d. When you pass 4 your program would print Not applicable

Task-7.2 Create a switch statement [Using ctime], In Which:

a. When you pass 1 your program would print current year b. When you pass 2 your program would print current month c. When you pass 3 your program would print current day d. When you pass 4 your program would print Not applicable

Task-7.3

v1. Print using reverse method:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1 Array and 2D Array related Questions in C++:

Task-7.1 Create a switch statement [Manual], In Which:

a. When you pass 1 your program would print current year b. When you pass 2 your program would print current month c. When you pass 3 your program would print current day d. When you pass 4 your program would print Not applicable

Task-7.2 Create a switch statement [Using ctime], In Which:

a. When you pass 1 your program would print current year b. When you pass 2 your program would print current month c. When you pass 3 your program would print current day d. When you pass 4 your program would print Not applicable

Task-7.3

v1. Print using reverse method:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

v2. Print using (10- arr[i][j]) method:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

v3. Restore using reverse method [without creating new array]:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

v4. Restore using (10- arr[i][j]) method [without creating new array]:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

Task-7.4 Restore the same values in the same array, arr[3][3]:

  1 2 3		1 1 1

      4 5 6     ==> 2 2 2

  7 8 9		3 3 3  

v1. Use row loop [int i, for all j]

v2. Use arr[i][N-1]/3, at each place

v3. Use, arr[i][j]-(2*i+j)

Task-7.5 Store these in an array[4][4] in given fassion and then print:

*

* *

* * *

* * * *

Task-7.6 Store these in an array[4][4] in given fashion and then print:

* * * *

  * * *

    * * 

      *

Task-7.7 Store these in an array[4][4] in given fashion and then print:

	  *

        * *

      * * *

    * * * *

Task-7.8 Store these in an array[4][4] in given fashion and then print:

* * * *

* * *

* * 

*

v2. Print using (10- arr[i][j]) method:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

v3. Restore using reverse method [without creating new array]:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

v4. Restore using (10- arr[i][j]) method [without creating new array]:

1 2 3 9 8 7

4 5 6 ==> 6 5 4

7 8 9 3 2 1

Task-7.4 Restore the same values in the same array, arr[3][3]:

  1 2 3		1 1 1

      4 5 6     ==> 2 2 2

  7 8 9		3 3 3  

v1. Use row loop [int i, for all j]

v2. Use arr[i][N-1]/3, at each place

v3. Use, arr[i][j]-(2*i+j)

Task-7.5 Store these in an array[4][4] in given fassion and then print:

*

* *

* * *

* * * *

Task-7.6 Store these in an array[4][4] in given fashion and then print:

* * * *

  * * *

    * * 

      *

Task-7.7 Store these in an array[4][4] in given fashion and then print:

	  *

        * *

      * * *

    * * * *

Task-7.8 Store these in an array[4][4] in given fashion and then print:

* * * *

* * *

* * 

*



Practical 8


Pointer, Function, Inline Function, Recursion in C++:

8.1 Task: Will the program through an error and if yes then why?

int *p = {10,20,20};

cout << *p;

p++;

cout << *p;

8.2 Task: Output of this program?

V1. Issue?

int arr[] = {10,20,30};

cout << *arr;

cout << arr;

arr++;

cout << *arr;

V2.How to resolve above issue?

int arr[] = {10,20,30};

cout << *arr;

cout << arr;

cout << *(?);

8.3 Task: Output of this program?

V1. Output?

int a = 10;

int *p;

int **q;

p = &a;

q = &p;

cou << *p;

cou << **q;

V2. Change the value of a using q pointer to pointer.

8.4 Task: Find factorial of a number using function but not recurssion

8.5 Task: Find factorial of a number using recurssion

8.6 Task: Series Problem using recurssion for n series

2, (2^2 + 2), (3^3 + 3), (4^4 + 4), (5^5 + 5), .......

Hint:

n * ((n-1)^(n-1) + (n-1))

8.7 Task: Perform Call by value, call by Address for swapping value of a and b:

int a = 10;

int b = 20;

V1. Swap(a,b); //call by Value [void swap(int a, int b){}]

V2. Swap(a,b); //call by Value [void swap(int &a, int &b){}]

V3. Swap(&a,&b); //call by Address

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published