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
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 |
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 |
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 |
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 |
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 |
Print all numbers which has a certain digit in a certain position eg: number=45687 1 number=4 2 number=5 etc
what is linkage error when it occurs in c program
why programs in c are running with out #include<stdio.h>? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }
What is true about the following C Functions (a) Need not return any value (b) Should always return an integer (c) Should always return a float (d) Should always return more than one value
disadvantages of realloc ?
Hierarchy decides which operator a) is most important b) is used first c) is fastest d) operates on largest numbers
What is the difference between formatted&unformatted i/o functions?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
Explain how can a program be made to print the name of a source file where an error occurs?
What is main return c?