Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

i have doubt im a new learner of c in some sentence we use( "%d",a) in scanf and sometimes in printf how do you find it?

+5 votes
asked Oct 2 by Subikshavani (170 points)

2 Answers

+1 vote
answered Oct 2 by Pessoua (460 points)
Could you expain your question further and give an example? Also the scanf you used should be ("%d, &a");
+2 votes
answered Oct 3 by Peter Minarik (80,320 points)

scanf() scans the standard input for a specific pattern. The pattern is provided in quotes. In your case, it is "%d", which means a decimal integer. Then it is stored at a given variable, to be precise, stored at the address of a given variable. You can get the address of the variable via the & operator, hence you have a & before your variables in scanf().

printf() prints to the standard output. It also uses a format specifier, similar to scanf(). However, you are printing a number here, so the compiler is not interested in the memory address of the variable, but the actual value stored in that variable (on that memory address), hence with printf() you do not use the & (memory address of) operator.

#include <stdio.h>

int main()
    int number;
    printf("Please, enter an integral number: ");
    scanf("%d", &number);
    printf("You entered: %d\n", number);

    return 0;

I hope this makes more sense now. Have fun learning!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.