What is the difference between %d and %*d in C

Answers were Sorted based on User's Feedback



What is the difference between %d and %*d in C..

Answer / meruva

%d means it prints only given value,
and %*d means it prints garbage value.
for eg: //it prints i value is=10
int i=10;
printf("i value is=%d",i);

//it prints garbage value
int i=10;
printf("i value is=%*d",i);

Is This Answer Correct ?    5 Yes 3 No

What is the difference between %d and %*d in C..

Answer / nithya

%d print the value for example
int x=2;
printf("x=%d",x);

output:

x=2

%*d print the value for example
int x=2;
printf("x=%*d",x);

output:

x= 2

the output two space(x=2) next the value will be display
(x=6) the output 6 space next the value will be display

Is This Answer Correct ?    0 Yes 0 No

What is the difference between %d and %*d in C..

Answer / ram

%d prints the given value,
%*d... used to print the mentioned length of given value

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More C Interview Questions

Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

1 Answers   CMS,


What is typedef struct in c?

0 Answers  


What is C language Terminator?

15 Answers   TCS,


program to print circle structure

1 Answers  


Which of the following data structures is on average the fastest for retrieving data: 1) Binary Tree 2) Hash Table 3) Stack

3 Answers  






Please write the area of a RIGHT ANGLED TRIANGLE.

1 Answers  


What is a #include preprocessor?

0 Answers  


What are the advantage of c language?

0 Answers  


Program to find largest of three numbers without using comparsion operator?

3 Answers  


Explain what is operator promotion?

0 Answers  


what is disadvantage of pointer in C

13 Answers   Tech Mahindra,


What are the 3 types of structures?

0 Answers  


Categories