how do i use scanf to read in one number and set it to two different variables?
Printable View
how do i use scanf to read in one number and set it to two different variables?
You use it to read into one variable, then copy the value of that variable over to the other variable.
Is this what you mean?
If not, give an example.Code:scanf("%d",&i);
j=k=i;
thats exactly what i mean. thank you very much.
i have made this to create part of a factorial table but i cant get it to only print the max factorial till it reaches the value entered for the minimum factorial. how would i go about that?Code:
#include <stdio.h>
void main()
{
int maxfactorial=0, minfactorial=0, line=0, factorial=0, i=0;
printf("enter max factorial\n");
scanf("%d", &i);
printf("enter min factorial\n");
scanf("%d", &minfactorial);
printf("--------------------------------------------------------------------");
while (line<=0){
printf("\nFactorial Value Factorial expression Result");
line=line+1;
}
maxfactorial=i;
factorial=i;
while ( factorial>0){
printf("\n%d" ,maxfactorial);
maxfactorial=maxfactorial-1;
factorial=factorial-1;
}
}