Questions for: Strings
#include<stdio.h>
int main()
{
char str[7] = "ExamAdept";
printf("%s\n", str);
return 0;
}
#include<stdio.h>
int main()
{
printf("India", "BIX\n");
return 0;
}
printf("India", "BIX\n"); It prints "India". Because ,(comma) operator has Left to Right associativity. After printing "India", the statement got terminated.
Discuss About this Question.
#include<stdio.h>
int main()
{
void fun();
fun();
printf("\n");
return 0;
}
void fun()
{
char c;
if((c = getchar())!= '\n')
fun();
printf("%c", c);
}
Step 1: void fun(); This is the prototype for the function fun().
Step 2: fun(); The function fun() is called here.
The function fun() gets a character input and the input is terminated by an enter key(New line character). It prints the given character in the reverse order.
The given input characters are "abc"
Output: cba
Discuss About this Question.
#include<stdio.h>
#include<string.h>
int main()
{
char str[] = "India\0\BIX\0";
printf("%s\n", str);
return 0;
}
A string is a collection of characters terminated by '\0'.
Step 1: char str[] = "India\0\BIX\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".
Discuss About this Question.
#include<stdio.h>
int main()
{
printf(5+"Good Morning\n");
return 0;
}
printf(5+"Good Morning\n"); It skips the 5 characters and prints the given string.
Hence the output is "Morning"
Discuss About this Question.
Discuss About this Question.