or cin.ignore() or while(getchar()!='\n'0; instead of only a getchar.....
On Fri, Jul 29, 2011 at 5:03 PM, sunny agrawal <[email protected]>wrote:
> when you enter two numbers and press Enter
> new line character is passed as character c
>
> Change your code as Follows:
>
>
> printf("do you want to continue(y/n):");
> getchar();
> scanf("%c",&c);
>
>
> On Fri, Jul 29, 2011 at 4:31 PM, nullpointer <[email protected]>wrote:
>
>> #include<stdio.h>
>> void add();
>> void subtract();
>> int main()
>> {int choice;
>> printf("enter your choice:1.add 2.subtract:");
>> scanf("%d",&choice);
>> switch(choice)
>> {case 1:
>> add();
>> break;
>> default:
>> printf("wrong choice entered");
>> }
>> }
>> void add()
>> {int a,b;
>> char c;
>> do
>> {printf("enter two numbers:");
>>
>> scanf("%d %d",&a,&b);
>>
>> printf("%d\n",a+b);
>>
>> printf("do you want to continue(y/n):");
>> scanf("%c",&c);
>> }while(c=='y'||c=='Y');
>> printf("\n");
>> }
>>
>> why second scanf inside do while not working???
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.