Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First try to predict the outcome of the following C program. Then, run it to find out whether your prediction was correct or not. Try

First try to predict the outcome of the following C program. Then, run it to find out whether your prediction was correct or not. Try to justify your observation using the concept of pointers in C. Hint: Please note that: p is a pointer initialized to letter 'o' in the string "hello world!" str which is the name of char array containing the "hello world!" string is considered to be the pointer to the first letter 'h' expression (p - str) subtracts a pointer from the other resulting in an integer counting how many characters can be fit between these two pointers. p[-2] is a character stored two letters before the current position that pointer p refers to p-- moves the pointer p backward in the string "hello world!" ++p moves the pointer p forward in the string "hello world! #include int main(){ char str[15] = "hello world!"; char* p = &str[4]; printf("%d %d %c %c %c", p - str, p[-2] - 'a', p[3] - 4, *(p--), *(++p)); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials Of Statistics For The Behavioral Sciences

Authors: Susan A. Nolan

3rd Edition

1464107777, 978-1464107771

More Books

Students also viewed these Algorithms questions

Question

1. Watch what students do with their free time.

Answered: 1 week ago

Question

What is a ceiling effect and how does it affect a distribution?

Answered: 1 week ago

Question

What is the SS total ?

Answered: 1 week ago