Computer Sciences > GATE 2025 SET-2 > C Programming
Consider the following C program:
Which ONE of the following will be the output of the program?

Correct : c
The correct answer is Option C — ello World!
The C program uses strchr to locate the first occurrence of a character in the string "Hello World!", then advances the pointer by 1 position past that character. The resulting pointer now points to the substring starting one character after ''H'' — which is "ello World!".
When this pointer is passed to printf or puts, it prints from that position to the end of the string, giving the output ello World! — note the capital ''H'' is skipped.
This is a classic pointer arithmetic question in C. strchr returns a pointer into the original string, and adding 1 to it simply moves one character forward without creating a new string.
Similar Questions
Consider the following two functions
void fun1(int n){
if(n == 0) return;
printf(“%d”, n);
fun2(n-2);
&...
Consider the C functions foo and bar given below:
int foo(int val)
{
int x = 0;
while (val > 0)
{
&nbs...
What is printed by the following ANSI C program?
#include<stdio.h>
int main(int argc, char *argv[])
{
int a[3][3][3] =
{{...
Total Unique Visitors
Loading......