2,543 views

1 Answer

Best answer
4 votes
4 votes

OUTPUT: Geeks Q

EXPLANATION

char *s = "Geeks Quiz";

Store the string "Geeks Quiz" in memory and stores the base address in pointer s.

printf("%.*s",n,s);

  1. .number:  Its a precision which specifies the minimum number of character/digits to be printed.
  2. .*: The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.
  3. Therefore, the above line will print 7 characters (as specified by n) of string s.

SOURCE: Tutorials Point (Click on link to read more about formatting in printf)

Ouput after executing the above code on Ideoneis here.

selected by

Related questions

1 votes
1 votes
0 answers
1
Abhisek Saha asked Oct 14, 2018
444 views
Please explain this.
7 votes
7 votes
3 answers
2
Parshu gate asked Nov 20, 2017
783 views
What is the output of the following program?#include<stdio.h int main() { int array[]={10, 20, 30, 40}; printf(“%d”, -2[array]); return 0; }$-60$$-30$$60$Garbage valu...
0 votes
0 votes
1 answer
3
stblue asked Oct 18, 2017
773 views
#include <stdio.h>int main(){ int a[] = {50, 60, 10, 30, 40, 20 }; int *b[] = {a+3, a+4, a, a+2, a+1, a+5 }; int c = b; c++; printf("%u, %u, %u\n", c-b, *...
0 votes
0 votes
1 answer
4
Desert_Warrior asked May 16, 2016
607 views
#include<stdio.h #include<stdlib.h int main() { char s[] = "Opendays2012"; int i = 0; while(*(s++)) i++; printf("%d",i); return 0; }(a) Segmentation Fault (b) Compile Err...