# Thread: 2nd scanf input problem.

1. ## 2nd scanf input problem.

program below not taking input of 2nd scanf ,whats the error?

Code:
```main()
{
int x,y,z;

printf("Enter tghe value of x,y,z : ");
scanf("%d,%d,%d",&x,&y,&z);
shift(x,y,z);
}

shift(int x,int y,int z)
{
char b;
int a;
a = z;
z = y;
y = x;
x = a;
printf(" x = %d \n y= %d \n z = %d",x,y,z);
printf("\nDO you want right circular shift again?(y/n): ");\
scanf("%c",&b); <=========================problem
if ( b == 'y')
{
shift(x,y,z);
}
}```

2. printf("Enter tghe value of x,y,z : ");
"the" is spelt wrong

3. thank you,it solved the problem of scanf,however the program is still not running due to "if" part.Can you please point out the error in "if" part of the program.thank you.

4. It seems ok... Can you post your new code please?

5. here is the new code.but its not running.My program name is test ,its giving error on command prompt :- 'test' is not recognized as an internal or external command,operable program or batch file.

Code:
```#include<stdio.h>

main()
{
int x,y,z;

printf("Enter tghe value of x,y,z : ");
scanf("%d,%d,%d",&x,&y,&z);
shift(x,y,z);
}

shift(int x,int y,int z)
{
char b;
int a;
a = z;
z = y;
y = x;
x = a;
printf(" x = %d \n y= %d \n z = %d",x,y,z);
printf("\nDO you want right circular shift again?(y/n): ");
scanf(" %c",&b);
if ( b=='y')
{
shift(x,y,z);
}
}```

6. The problem does not come from the code. Try to create a new program and write there your code. If the problem persists, you probably have a configuration problem.

7. Thank you for the quick reply ....(by the way are you sure it runs fine?)

8. Check the article for indent style.

You forgot to correct your typo in line 7, as SirPrattlepod noted before.

Moreover, you need a prototype for your function.

So, either you place your function above main, or you leave the function where it is now, and you place a prototype (a declaration) of the function above main. If you do not get what I said, read this very brief code for the very basics in functions.
I would also suggest you to specify the return type of your function to void, since it does return anything.

9. Those were exactly the points I was going to make

The code does run correctly though. That error means that windows can't find a test.exe to run, nothing more, nothing less. Are you in the same directory as test.exe?

10. Originally Posted by smokeyangel
Those were exactly the points I was going to make
Sorry that I took your turn.

11. Made some changes and it works really good now.Thanks for the "return" advice.it was dumb of me.
Bytheway saw your cv,blown away by your achievements dude.Keep it up
hewre is the code,let me know if you can make it more simpler or compact than this .
Code:
```#include<stdio.h>

main()
{
int x,y,z;
char b;
printf("Enter the value of x,y,z : ");
scanf("%d,%d,%d",&x,&y,&z);
shift(&x,&y,&z);
printf(" x = %d \n y= %d \n z = %d",x,y,z);
printf("\nDO you want right circular shift again?(y/n): ");
scanf(" %c",&b);
while ( b=='y')
{
shift(&x,&y,&z);
printf(" x = %d \n y= %d \n z = %d",x,y,z);
printf("\nDO you want right circular shift again?(y/n): ");
scanf(" %c",&b);
}
return 0;
}

shift(int *j,int *k,int *l)
{

int a;
a = *l;
*l = *k;
*k = *j;
*j = a;

}```

12. yup,maybe its some config error,but hey if found another way ...thnx for the reply and help buddy

13. Thank you for the good words of you for the CV.

I am really glad you made all this changes yourself. Bravo. The last thing I would say, is to read again the Indent Style I posted before. It requires a little effort, but has a very good impact.

And something you haven't get taught yet.
We write
Code:
```int main(void)
{
...
return 0;
}```
The reason is that main() is a function too! And as you now know, functions have a return type. main() however is not just a function, it's the MAIN function that every program needs to have. In other words, you must have a main() function.
So, in order to let others (the system in which your code runs for example), that everything went as expected, you return a code that implies success. 0 is usually used for this.
However, since many disagree in the numbers which should be used, you can use macros, such as EXIT_SUCCESS for this purpose. But I think return 0; is just fine.

As for the configuration problem, try to create a new project and run it.. If this doesn't work, ask here again and someone may know the answer!

Bravo again for the beautiful transformation you did in your code.

14. k.Always good to learn new things.And good to have a good fellow coding enthusiast by side.

Popular pages Recent additions