Beginner in C programming

Joined
Jul 17, 2025
Messages
1
Reaction score
0
#include <stdio.h>

int main() {

int age =25;

printf("%d", age);

return 0;
}
This is my code why do I need this :%, inside
 
Joined
Jul 4, 2023
Messages
607
Reaction score
81
The part you're asking about: %d, is a format specifier used by printf.

What does "%d" do?

  • The printf function in C is used to print output to the screen.
  • The %d inside the double quotes tells printf to: "Insert an integer value here".
  • The d stands for "decimal" (i.e., a base-10 number).

SpecifierMeaningExample
%dInteger (decimal)printf("%d", 10);
%fFloating point (decimal)printf("%f", 3.14);
%cSingle characterprintf("%c", 'A');
%sString (text)printf("%s", "Hi");
 
Joined
Jul 4, 2023
Messages
607
Reaction score
81
BTW,

Online C code example that works
C:
#include <stdio.h>

int main() {

  int variable_1 = 10;
  float variable_2 = 10.20;
 
  printf("d");
  printf("\n");
 
  printf("%d", variable_1);
  printf("\n");
 
  printf("%d d", variable_1);
  printf("\n");
 
  printf("%d d - %f f", variable_1, variable_2);
  printf("\n");
 
  printf("Lorem ipsum %d. Lorem ipsum %f. Lorem ipsum %.2f.", variable_1, variable_2, variable_2);

  return 0;
}
 
Joined
Oct 8, 2025
Messages
1
Reaction score
0
#include <stdio.h>

int main() {

int variable_1 = 10;
float variable_2 = 10.20;
char variable_3[] = "Tamizh";
char variable_4 = 'M';

printf("d");
printf("\n");

printf("%c Initial", variable_4);
printf("\n");

printf("%s Greetings", variable_3);
printf("\n");

printf("%d", variable_1);
printf("\n");

printf("%d d", variable_1);
printf("\n");

printf("%d d - %f f", variable_1, variable_2);
printf("\n");

printf("Lorem ipsum %d. Lorem ipsum %f. Lorem ipsum %.2f.", variable_1, variable_2, variable_2);

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,341
Messages
2,571,399
Members
48,793
Latest member
evajons

Latest Threads

Top