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.

how do i use scanf in an if else function to output a print statement from the input

+2 votes
asked Jan 8 by george pearse (140 points)

1 Answer

+2 votes
answered Jan 9 by Peter Minarik (45,000 points)

scanf() does not output anything, it reads from the standard input.

Maybe can you share some code or explain in more detail what you're after?

Here's a silly example using scanf() and printf():

#include <stdio.h>

int main()
{
    int age;
    printf("How old are you? ");
    scanf("%d", &age);
    if (age >= 18)
        printf("You are legally and adult.\n");
    else
        printf("You are legally not an adult yet.\n");

    return 0;
}
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.
...