UrbanPro

Learn Advanced Placement Tests Coaching from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

void main ( )
{
int a [4];
int *p;
P=a;
*P=10;
P++;
*P=20;
P=&a[2];
*P=30
for (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 Questions

How do apprach to an unknown problem to construct its solution? Especially when do you face any programming challenge.

First approach your teacher or tutor about problem statement and ask for solution to get it solved.. Next practise similar kind of things by using other books or google or youtube help... If you u facing any challenges...
Tanmoy Gupta
0 0
8
Who is father of microbiology?
Antonie Phillips van Leewenhoek circa1759 is known as the father of microbiology and the microscope due to his early study of bacteria. He was a Dutch scientist. Antonie Van Leeuwenhoek a Dutch, who saw...
Sukhman
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

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...

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:...

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
X

Looking for Advanced Placement Tests Coaching Classes?

The best tutors for Advanced Placement Tests Coaching Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Advanced Placement Tests Coaching with the Best Tutors

The best Tutors for Advanced Placement Tests Coaching Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more