scanf string code example

Example 1: scanf c

scanf("%d", &b);

Example 2: scanf

#include <stdio.h>
int main()
{
    int a;
    float b;

    printf("Enter integer and then a float: ");
  
    // Taking multiple inputs
    scanf("%d%f", &a, &b);

    printf("You entered %d and %f", a, b);  
    return 0;
}

Example 3: C why is is & nit used in scan f fr string

/*
‘&’ is used to get the address of the variable. 
C does not have a string type, String is just an array of 
characters and an array variable stores the address of the 
first index location.
*/

Tags:

Misc Example