im a beginner with a not so good teacher and trying to figure things out on my own...
#include<stdio.h>
#include<conio.h>
int n,x,c,a;
main()
{
scanf("%d",&n);
do
{
scanf("%d",&x);
a=x;
c++;
}
while(c!=n);
printf("%d",a);
}
in this code, i'd like to know if it's possible to change the 'a' in (a=x;) to, lets say 'b' then 'c', then 'd'.... i want to store the different values from scanf("%d",&x); in different variables.
Example, if i enter the values, 1,2,3,4, i'd like the output to be a=1,b=2,c=3,d=4
thanks for the help
scanffor return values. Initialise variablesc. It works now because global variables are zero-initialized, but if you makeca local variable it will not be initialized andcwould have an indeterminate value, and using it uninitialized would lead to undefined behavior. And you really should make the variables local, having global variables is considered a big no-no by most.cbefore thedo/whileloop. Right now it works, but you should do it to avoid potential problems with it