how to scanf in c code example
Example 1: how to scanf in c
#include <stdio.h>
int main()
{
int testInteger;
printf("Enter an integer: ");
scanf("%d", &testInteger);
printf("Number = %d",testInteger);
return 0;
}
Example 2: c scanf
scanf("%d",&variable);
/*
% is a format specifier
%d or %i for int
%ld or %li for long int
%f for float
%lf for double
%c for char
%s for string
*/
Example 3: scanf c
scanf("%d", &b);
Example 4: scanf in c
#include <stdio.h>
int main () {
scanf("%s", str);
printf("%s"str);
scanf("%d", int);
printf("%d"int);
return(0);
}