AI Programming
11.2K subscribers
594 photos
42 videos
245 files
569 links
An artificial intelligence free resource channel for students, professionals, and anyone who wants to learn how to solve problems.

ENGINEERING πŸŽ– PROGRAMMING πŸŽ– TIPS & HACKS

https://youtube.com/c/AIProgramming
CONTACT US ON: @alphadmin12
Download Telegram
Ex. Q 13. Compare String
Database SQL Commands
AI Programming
Photo
Explain of⬆️⬆️⬆️
1, #include <iostream>
using namespace std;

int main()
{
const int i = 20;
const int* const ptr = &i;
(*ptr)++;
int j = 15;
ptr = &j;
cout << i;
return 0;
}
Options:
a. 20
b. 21
c. 15
d. Compile error
3. What will be the output of the following program?

#include <iostream>
using namespace std;
int main()
{
int num[5];
int* p;
p = num;
*p = 10;
p++;
*p = 20;
p = &num[2];
*p = 30;
p = num + 3;
*p = 40;
p = num;
*(p + 4) = 50;
for (int i = 0; i < 5; i++)
cout << num[i] << ", ";
return 0;
}
Options:
a. 10, 20, 30, 40, 50
b. 10, 20, 30, 40, 50,
c. compile error
d. runtime error
4. What will be the output of the following program?

#include <iostream>
using namespace std;
int main()
{
int arr[] = { 4, 5, 6, 7 };
int* p = (arr + 1);
cout << *arr + 10;
return 0;
}
Options:
a. 12
b. 15
c. 14
d. error
5 What would be printed from the following C++ program?

#include <iostream>
using namespace std;
int main()
{
int x[5] = { 1, 2, 3, 4, 5 };
// p points to array x
int* p = x;
int i;
// exchange values using pointer
for (i = 0; i < 2; i++) {
int temp = *(p + i);
*(p + i) = *(p + 4 - i);
*(p + 4 - i) = temp;
}
// output the array x
for (i = 0; i < 5; i++)
cout << x[i] << " ";
return 0;
}
a) 5 4 3 2 1
b) 1 2 3 4 5
c)Address of the elements
d) Can’t say
6. What will be the output of the following program?

#include <iostream>
using namespace std;

int main()
{
int a = 32, *ptr = &a;
char ch = 'A', &cho = ch;

cho += a;
*ptr += ch;
cout << a << ", " << ch << endl;
return 0;
}
Options:
a. 32, A
b. 32, a
c. 129, a
d. 129, A
πŸ‘1
7,What would be printed from the following C++ program?

#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
float x = 5.999;
float* y, *z;
y = &x;
z = y;
cout << x << ", " << *(&x) << ", " << *y << ", " << *z << "\n";
return 0;
}
a) 5.999, 5.999, 5.999, 5.999
b) 5.999, 5.9, 5.000, 5.900
c) Address of the elements
d) compilation error
8 What would be printed from the following C++ program?

#include <iostream>
using namespace std;

int main()
{
int track[] = { 10, 20, 30, 40 }, *striker;

striker = track;
track[1] += 30;
cout << "Striker>" << *striker << " ";
*striker -= 10;
striker++;
cout << "Next@" << *striker << " ";
striker += 2;
cout << "Last@" << *striker << " ";
cout << "Reset To" << track[0] << " ";

return 0;
}
a) 10, 20, 30, 40
b) Striker>10 Next@50 Last@40 Reset To0
c) Striker>10 Next@40 Last@50 Reset To0
d) Striker> Next@ Last@ Reset To
Q 9 - Choose the respective delete operator usage for the expression β€˜ptr=new int[100]’.

A - delete ptr;

B - delete ptr[];

C - delete[] ptr;

D - []delete ptr;
10 - What is the output of the following program?

#include<iostream>

using namespace std;
main() {
char s[] = "Fine";
*s = 'N';

cout<<s<<endl;
}
A - Fine

B - Nine

C - Compile error

D - Runtime error
int c, *pc;
pc=c; /* Wrong! pc is address whereas, c is not an address. */
*pc=&c; /* Wrong! *pc is the value pointed by address whereas, %amp;c is an address. */
pc=&c; /* Correct! pc is an address and, %amp;pc is also an address. */
*pc=c; /* Correct! *pc is the value pointed by address and, c is also a value. */
πŸ‘‰πŸ‘‰answer 1- 10
1 d compiler error
3 b 10, 20 ,30 ,40, 50,
4 c 14
5 a 5 4 3 2 1
6 c 129, a
7 a 5.999, 5.9999, 5.9999, 5.999
8 b) Striker>10 Next@50 Last@40 Reset To0
9 c delete[] tr;
10 b Nine
Output Questions

πŸ˜³πŸ˜³πŸ˜³πŸ˜³πŸ˜³πŸ˜³πŸ˜³πŸ˜³πŸ˜³πŸ‘
Question 1.
Find the output of the following program. Assume all required header files are already being included in the program.

void Position(int &C1, int C2 = 3)
{
C1 += 2;
C2 += 1;
}
int main()
{
int P1 = 20, P2 = 4;
Position(P1);
cout << P1 << ", " << P2 << endl;
Position(P2, P1);
cout << P1 << ", " << P2 << endl;
} a, πŸ‘†22, 4 b✌20, 4
22, 6 22, 6
πŸ‘1
2 What is the output of this program?

#include <iostream>
using namespace std;
void copy (int& a, int& b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
}
int main ()
{
int x = 1, y = 3, z = 7;
copy (x, y, z);
cout << "x =" << x << ", y =" << y << ", z =" << z;
return 0;
}
a) 2 5 10πŸ‘†
b) 2 4 5✌
c) 2 6 14πŸ‘Œ
d) none of the mentionedπŸ‘
πŸ‘2