Q&A Discussões
When I enter two numbers the sum is displayed.. but when I input character as yes not y... Then it goes into an infinite loop... can anyone explain why?
int a,b;
char ch;
do
{
cout<<"Enter two numbers: ";
cin>>a>>b;
cout<<"The sum is "<<a+b
<<"\nDo you want to try again (y/n): ";
cin>>ch;
}while(ch=='Y'||ch=='y');
0 Voto
4 RespostasWhen I enter two numbers the sum comes.. but when I input character as yes not y... Then it goes into an infinite loop... can anyone explain why?
int a,b;
char ch;
do
{
cout<<"Enter two numbers: ";
cin>>a>>b;
cout<<"The sum is "<<a+b
<<"\nDo you want to try again (y/n): ";
cin>>ch;
}while(ch=='Y'||ch=='y');
0 Voto
2 RespostasWhat is the output and why?
public static int[] make (int n){
int[]a=new int [n];
a [i]=i+1;
}
return a;
}
public static void dub (int []jub){
for (intent i=0;i <jub.length;i++){
jub*=2;
}
}
public static int mus (int []zoo){
int jus=0;
for (int i=0;i <zoo.length;i++){
jus+=zoo [i];
}
return jus;
}
public static void main (String [] args){
int [] bob =make(5);
dub (bob);
System.out.println (mus (bob));
}
0 Voto
2 RespostasQuente hoje
Sticky position
2 Votes
Help please?
3 Votes
Online voting system
2 Votes
What is that z for
0 Votes
Suggestions needed
4 Votes
SQL practice
2 Votes
Game development
0 Votes
Ruby programming?
3 Votes