main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
Find the Outputs?

Answers were Sorted based on User's Feedback



main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / sumeet

Samco Systems
amco Systems

this will be the answer .. the reason being the ascii value
of r will be incremented so it now point to s( capital s
that is ) this account for (*ptr)++

next ptr++ will simply move you to the next charachter ..

Is This Answer Correct ?    20 Yes 7 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / ruchi

Turbo c will give an answer
samco system
amco system
pointer ptr is at r
by(*ptr)++ we are incrementing it by one so we get s
by ptr ++ we are incrementing the addrestion of ptr so it
will give an output amco system;
but gcc compiler will not give any answer it will print
segmentation fault

Is This Answer Correct ?    7 Yes 0 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / lucky

samco system
amco system

Is This Answer Correct ?    10 Yes 6 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / madhu

segmentation fault.U can give that as *(ptr+1)

Is This Answer Correct ?    8 Yes 6 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / chappa

The first increment is incorrect, since it will try to
increment the value of 'R' but will end up giving
Segmentation fault.

Second ptr++ is valid as it will shift the pointer from 'R'
to 'a'. The second print statement would have printed "amco
Systems", the compiler gives Seg fault due to the previous
incorrect increment.

Is This Answer Correct ?    2 Yes 0 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / guest

error

Is This Answer Correct ?    6 Yes 5 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / dhakchin moorthy.p

first printf stmt prints Ramco Systems
the error is in line ptr++;here u r trying to increment the
address holding by the pointer,pointer var may lost the
starting address.

Is This Answer Correct ?    0 Yes 1 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / soundar

Address of the variable will be displayed for the first
printf stmt

previous address will be incremented and current address of
variable will displayed for second printf stmt

Is This Answer Correct ?    3 Yes 8 No

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%..

Answer / vignesh1988i

Samco systems
amco systems



thank u

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More C Interview Questions

c program to add and delete an element from circular queue using array

3 Answers  


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

0 Answers  


how to use virual function in real time example

1 Answers   CTS, Wipro,


Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.

1 Answers  


What kind of structure is a house?

0 Answers  


Can you apply link and association interchangeably?

0 Answers   InterGraph,


can u suggest me am in a confusion to choose whether to go to c programming or a software testing . am a graduate in B.sc(electronics).

1 Answers  


what is the use of call back function in c?tell me with example

2 Answers   Bosch,


Why ordinary variable store only one value  

0 Answers  


Explain how do you determine whether to use a stream function or a low-level function?

0 Answers  


what are the languages used in c#?

3 Answers   Infosys,


dennis ritchie invented C language in AT&T bell laboratory what is the extension of AT&T?

4 Answers  


Categories