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

hello friends what do u mean by BUS ERROR i got this error while i am doing my program in DATA STRUCTURES

2 Answers   Wipro,


What is table lookup in c?

0 Answers  


difference between semaphores and mutex?

1 Answers  


Can we access array using pointer in c language?

0 Answers  


second highest number in a given set of numbers

3 Answers   TCS,






Q. where is the below variables stored ? - volatile, static, register

3 Answers   Bosch,


What is the difference between null pointer and wild pointer?

0 Answers  


Write a program to maintain student’s record. Record should not be available to any unauthorized user. There are three (3) categories of users. Each user has its own type. It depends upon user’s type that which kind of operations user can perform. Their types and options are mentioned below: 1. Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record) 2. Super Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record, Delete Single Record) 3. Guest (Search Record [by Reg. No or Name], View All Records) When first time program runs, it asks to create accounts. Each user type has only 1 account (which means that there can be maximum 3 accounts). In account creation, following options are required: Login Name: <6-10 alphabets long, should be unique> Password: <6-10 alphabets long, should not display characters when user type> Confirm Password: <must match with the Password, should not display characters when user type> Account Type: <One character long, A or S or G where A for Admin, S for Super Admin, G for Guest> Login Name, Password and Account Type should be stored in a separate file in encrypted form. (Encryption means that actual information should be changed and Decryption means that Encrypted information is changed back to the actual information) If any of the above mentioned requirement(s) does not meet then point out mistake and ask user to specify information again. When Program is launched with already created accounts, it will ask for user name and password to authenticate. On successful authentication, give options according to the user’s type.

0 Answers  


Write a program in C to reverse a number by recursive function?

1 Answers  


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

1 Answers   TCS,


main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain

1 Answers  


write a program for size of a data type without using sizeof() operator?

22 Answers   HCL, IBM,


Categories