What will be the output of the program? int main() { char p[] = - ProProfs Discuss
Topics
Products
Follow Us:

What will be the output of the program? int main() { char p[] = "%d\n"; p[ = 'c'; printf(p, 65);  return 0; }
A. A
B. A
C. C
D. 65

Asked by Danish, Last updated: Jul 04, 2020

+ Answer
Request

1 Answer

John Smith

John Smith

Answered Sep 09, 2016

A
char p[] = %d ; The variable p is declared as an array of characters and initialized with string %d. p[1] = c; Here, we overwrite the second element of array p by c. So array p becomes %c. printf(p, 65); becomes printf(%c, 65); Therefore it prints the ASCII value of 65. The output is A.
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.