-
Notifications
You must be signed in to change notification settings - Fork 0
/
Qualcomm-Q1.cpp
30 lines (28 loc) · 898 Bytes
/
Qualcomm-Q1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//============================================================================
// Name : Qualcomm-Q1.cpp
// Author : Aref Abedjooy
// Version : 1.0
// Copyright : Copyright (c) 2022, Aref Abedjooy. No Rights Reserved.
// Description : Q1 mentioned in https://www.youtube.com/watch?v=rf317vRyifU
//============================================================================
#include <iostream>
using namespace std;
struct Node
{
int a;
int b;
};
int main()
{
struct Node *ptr = NULL; // It is definition of a null pointer.
cout << ptr << endl; // output is 0
cout << true << endl; // output is 1
if (ptr && ptr->a)
{ // becuase insdie if condition is 0 and zero means false in c++,
// these line inside if will not be run.
ptr->a = 2;
cout << ptr << ptr->a << endl;
}
cout << "reached outside if";
return 0;
}