#include <stdio.h>
int main()
{
char a[] = "atnyla";
printf("%s\n", a);
return 0;
}
atnyla
The %s format specifier is implemented for representing strings. This is used in printf() function for printing a string stored in the character array variable. When you have to print a string, you should implement the %s format specifier.
printf("%s",<variable name>);
The given code is a C program that declares a character array a and initializes it with the string "atnyla". The printf() function is then used with the %s format specifier to print the contents of the a array to the console.
Here's how it works:
#include line includes the standard input/output library in the program.main() function is the entry point of the program.a is declared and initialized with the string "atnyla".printf() function is used to display the contents of a using the %s format specifier.
%s is a format specifier used to display a string of characters.\n character is used to insert a newline after the output is printed.return 0; statement terminates the program and returns 0 to the operating system indicating that the program executed successfully.First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.