Strings

Q1: What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    char str[] = "India\0\Aptitude\0";
    printf("%s\n", str);
    return 0;
}

A Aptitude

B India

C India Aptitude

D India\0Aptitude

ANS:B - India

A string is a collection of characters terminated by '\0'. Step 1: char str[] = "India\0\Aptitude\0"; The variable str is declared as an array of characters and initialized with value "India" Step 2: printf("%s\n", str); It prints the value of the str. The output of the program is "India".



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.