void main ( ){int a [4];int *p;P=a;*P=10;P++;*P=20;P=&a[2];*P=30for (int i=0; i<3; i++)cout <<a[i] <<" , " , Write output

Asked by Last Modified  

Follow 4
Answer

Please enter your answer

20+ years experienced IT Trainer expertise in C, C++, JAVA, Python, RDBMS and Networking

Hi Anya, your code is full of syntactical errors. Rectified cde is as follows: #include <iostream>using namespace std; int main() { int a; // Array of size 4 int *p; // Pointer to integer p = a; // Assign the address of the first element of array 'a' to pointer 'p' *p = 10; // Set the value at...
read more
Hi Anya, your code is full of syntactical errors. Rectified cde is as follows: #include <iostream>using namespace std; int main() { int a[4]; // Array of size 4 int *p; // Pointer to integer p = a; // Assign the address of the first element of array 'a' to pointer 'p' *p = 10; // Set the value at the memory location pointed to by 'p' (i.e., a[0]) to 10 p++; // Move pointer to the next element in the array *p = 20; // Set the value at the memory location pointed to by 'p' (i.e., a[1]) to 20 p = &a[2]; // Set pointer 'p' to point to the third element of the array 'a' *p = 30; // Set the value at the memory location pointed to by 'p' (i.e., a[2]) to 30 // Loop to print the first three elements of the array for (int i = 0; i < 3; i++) { cout << a[i] << " , "; // Print the array values followed by commas } return 0;} Output: 10 , 20 , 30 , read less
Comments

Related Lessons

Short Answer Questions For Chapter-2 Computer Science Class-XI-CBSE
Short Answer Questions: 1. What is Bit? Ans: The smallest and basic unit of information in digital computer is called a bit. Bit is the abbreviation of Binary Digit. 2. What do you mean by base/radix? Ans:...

About Us
To fulfill the dream of Govt. of India, ”Information Technology for everyone”, and to fulfill the needs of 28 Lakhs IT professional till 2017 and other jobs related to this factor and giving...

Recommended Articles

Why Study Abroad? With every passing year, the number of students from India applying for overseas education is increasing.  Here, let us explore why studying abroad has become such a popular option for students of all ages. Study Abroad Benefits A wide variety of programs and world class faculty: One of...

Read full article >

Once you decide to go abroad to pursue your studies, an extensive preparation is necessary. Following a step-by-step process helps you achieve your goal without getting overwhelmed by the number of things that need to be done! I. Planning: - 1. What, where and when? First decide what kind of program you want to...

Read full article >

Bank P.O is one of the most talked about examination for bank recruitment in India. P.O stands for Probationary Officer which is an entry level position in banks, which are especially for fresh graduates or a person without any prior experience. The probation period for Bank P.Os is generally 2 years in which they’re trained...

Read full article >

It is not true that every student is lethargic and loves to be the couch potato. Some students do put immense effort for their examinations. Where some book-worms study day in and out without a break, with an ultimate objective to crack the competitive examination or to score the highest mark. But, the saddest part is that,...

Read full article >

Looking for Advanced Placement Tests Coaching classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you