shoba


{ City } chennai
< Country > india
* Profession * hr
User No # 125360
Total Questions Posted # 17
Total Answers Posted # 19

Total Answers Posted for My Questions # 19
Total Views for My Questions # 7495

Users Marked my Answers as Correct # 2
Users Marked my Answers as Wrong # 4
Questions / { shoba }
Questions Answers Category Views Company eMail

Write a C++ Program to Display Number (Entered by the User).

1 C++ 264

Identify the error in the following program. #include void main() { int i = 0; i = i + 1; cout « i « " "; /*comment *//i = i + 1; cout << i; }

1 C++ 250

Write a program to display the following output using a single cout statement Maths=90 Physics=77 Chemistry = 69

2 C++ 671

Write a C++ Program to find Square Root of a number using sqrt() function.

1 C++ 433

Write a C++ Program to Find Sum and Average of three numbers.

1 C++ 272

Write a program to read two numbers from the keyboard and display the larger value on the screen

1 C++ 334

Write a C++ Program to Find whether given Number is Odd or Even.

1 C++ 395

Write a C++ Program to Reverse a Number using while loop.

1 C++ 382

Write a program to input an integer from the keyboard and display on the screen “WELL DONE” that many times.

1 C++ 787

Write a C++ Program to Find Sum and Average of n numbers using for loop.

1 C++ 411

Write a program to read the values a, b and c and display x, where x=a/b–c. Test the program for the following values: (a) a = 250, b = 85, c = 25 (b) a = 300, b = 70, c = 70

1 C++ 553

Identify the error in the following program. include using namespace std; void main() { int num[]={1,2,3,4,5,6}; num[1]==[1]num ? cout<<"Success" : cout<<"Error"; }

1 C++ 400

Identify the errors in the following program. #include using namespace std; void main() { int i=5; while(i) { switch(i) { default: case 4: case 5: break; case 1: continue; case 2: case 3: break; } i-; } }

1 C++ 570

Write a C++ Program to Check Whether a character is Vowel or Consonant.

2 C++ 340

Write a C++ Program to find Addition of Two Numbers.

1 C++ 280


 [1]   2    Next



Answers / { shoba }

Question { 264 }

Write a C++ Program to Display Number (Entered by the User).


Answer

Solution:
/* C++ Program to Display Number (Entered by the User) */
#include
using namespace std;
int main()
{
int number;
cout << "Enter an integer :: ";
cin >> number;
cout << "
The Number entered is :: " << number<<"
";
return 0;
}
Output:
/* C++ Program to Display Number (Entered by the User) */
Enter an integer :: 8
The Number entered is :: 8
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Question { 250 }

Identify the error in the following program.
#include
void main()
{
int i = 0;
i = i + 1;
cout « i « " ";
/*comment *//i = i + 1;
cout << i;
}


Answer

/* comment*//i=i+1; -> Syntax error

Is This Answer Correct ?    0 Yes 0 No


Question { 671 }

Write a program to display the following output using a single cout statement
Maths=90
Physics=77
Chemistry = 69


Answer

#include
#include
using namespace std;
int main()
{

char *sub[]={"Maths","Physics","Chemestry"};
int mark[]={90,77,69};
for(int i=0;i<3;i++)
{
cout< }
return 0;
}
Output:
Maths=90
Physics=77
Chemistry=69

Is This Answer Correct ?    0 Yes 0 No

Question { 671 }

Write a program to display the following output using a single cout statement
Maths=90
Physics=77
Chemistry = 69


Answer

#include
#include
using namespace std;
int main()
{

char *sub[]={"Maths","Physics","Chemestry"};
int mark[]={90,77,69};
for(int i=0;i<3;i++)
{
cout< }
return 0;
}
Output:
Maths=90
Physics=77
Chemistry=69

Is This Answer Correct ?    0 Yes 0 No

Question { 433 }

Write a C++ Program to find Square Root of a number using sqrt() function.


Answer

Solution:
/* C++ Program to find Square Root of a number using sqrt() function */
#include
#include
using namespace std;
int main()
{
float sq,n;
cout<<"Enter any positive number :: ";
cin>>n;
sq=sqrt(n);
cout<<"
Square root of Entered Number [ "< ";
return 0;
}
Output:
/* C++ Program to find SquareRoot of a number using sqrt() function */
Enter any positive number :: 10000
Square root of Entered Number [ 10000 ] is :: 100
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Question { 272 }

Write a C++ Program to Find Sum and Average of three numbers.


Answer

Soluion:
/* C++ Program to Find Sum and Average of three numbers */
#include
using namespace std;
int main()
{
float a,b,c,sum,avg;
cout<<"Enter 1st number :: ";
cin>>a;
cout<<"
Enter 2nd number :: ";
cin>>b;
cout<<"
Enter 3rd number :: ";
cin>>c;
sum=a+b+c;
avg=sum/3;
cout<<"
The SUM of 3 Numbers [ "< ";
cout<<"
The AVERAGE of 3 Numbers [ "< ";
return 0;
}
Output:
/* C++ Program to Find Sum and Average of three numbers */
Enter 1st number :: 3
Enter 2nd number :: 4
Enter 3rd number :: 5
The SUM of 3 Numbers [ 3 + 4 + 5 ] = 12
The AVERAGE of 3 Numbers [ 3, 4, 5 ] = 4
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Question { 334 }

Write a program to read two numbers from the keyboard and display the larger value on the screen


Answer

#include
#include
using namespace std;
int main()
{
float a,b;
cout<<" Enter two values :"< cin>>a>>b;
if(a>b)
cout<<" larger value = "< else
cout<<" larger value = "< return 0;
}
OUTPUT:
Enter two values:10 20
Larger value:20

Is This Answer Correct ?    1 Yes 0 No

Question { 395 }

Write a C++ Program to Find whether given Number is Odd or Even.


Answer

Solution:
/* C++ Program to Find whether given Number is Odd or Even */
#include
using namespace std;
int main()
{
int a;
cout<<"Enter any positive number :: ";
cin>>a;
if(a%2==0)
{
cout<<"
The Entered Number [ "< ";
}
else
{
cout<<"
The Entered Number [ "< ";
}
return 0;
}
Output:
/* C++ Program to Find whether given Number is Odd or Even */
Enter any positive number :: 1327
The Entered Number [ 1327 ] is ODD Number.
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Question { 382 }

Write a C++ Program to Reverse a Number using while loop.


Answer

Solution:
/* C++ Program to Reverse a Number using while loop */
#include
using namespace std;
int main()
{
int no,rev=0,r,n;
cout<<"Enter any positive number :: ";
cin>>n;
no=n;
while(no>0)
{
r=no%10;
rev=rev*10+r;
no=no/10;
}
cout<<"
Reverse of a Number [ "< ";
return 0;
}
Output:
/* C++ Program to Reverse a Number using while loop */
Enter any positive number :: 123456
Reverse of a Number [ 123456 ] is :: [ 654321 ]
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Question { 787 }

Write a program to input an integer from the keyboard and display on the screen “WELL DONE” that many times.


Answer

#include
#include
using namespace std;
int main()
{
int n;
char *str;
str="WELL DONE";
cout<<" Enter an integer value ";
cin>>n;
for(int i=0;i {
cout< }
return 0;
}
OUTPUT:
Enter an integer value 5
WELL DONE
WELL DONE
WELL DONE
WELL DONE
WELL DONE

Is This Answer Correct ?    0 Yes 2 No

Question { 411 }

Write a C++ Program to Find Sum and Average of n numbers using for loop.


Answer

Solution:
/* C++ Program to Find Sum and Average of n numbers using for loop */
#include
using namespace std;
int main()
{
int i,n,x,sum=0;
float avg;
cout<<"How many numbers u want to enter :: ";
cin>>n;
for(i=1;i<=n;++i)
{
cout<<"
Enter number "< cin>>x;
sum+=x;
}
avg=(float)sum/(float)n;
cout<<"

Sum of "< cout<<"

Average of "< cout<<"
";
return 0;
}
Output:
/* C++ Program to Find Sum and Average of n numbers using for loop */
How many numbers u want to enter :: 6
Enter number 1 :: 1
Enter number 2 :: 2
Enter number 3 :: 3
Enter number 4 :: 4
Enter number 5 :: 5
Enter number 6 :: 6
Sum of 6 Numbers :: 21
Average of 6 Numbers :: 3.5
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

Question { 553 }

Write a program to read the values a, b and c and display x, where
x=a/b–c.
Test the program for the following values:
(a) a = 250, b = 85, c = 25
(b) a = 300, b = 70, c = 70


Answer

#include
#include
using namespace std;
int main()
{
float a,b,c,x;
cout<<" Enter the value of a,b, &c :"< cin>>a>>b>>c;
if((b-c)!=0)
{
x=a/(b-c);
cout<<" x=a/(b-c) = "< }
else
{
cout<<" x= infinity "< }
return 0;
}
OUTPUT:
Enter the value of a,b,&c:300 70 70
X=infinity

Is This Answer Correct ?    1 Yes 2 No

Question { 400 }

Identify the error in the following program.
include
using namespace std;
void main()
{
int num[]={1,2,3,4,5,6};
num[1]==[1]num ? cout<<"Success" : cout<<"Error";
}


Answer

num [1] = [1] num?. You should write index number after array name but here index number is mention before array name in [1] num
So expression syntax error will be shown.
Correction : num[1] = num[1]? is the correct format.

Is This Answer Correct ?    0 Yes 0 No

Question { 570 }

Identify the errors in the following program.
#include
using namespace std;
void main()
{
int i=5;
while(i)
{
switch(i)
{
default:
case 4:
case 5:
break;
case 1:
continue;
case 2:
case 3:
break;
}
i-;
}
}


Answer

case 1 :
continue;
The above code will cause the following situation:
Program will be continuing while value of i is 1 and value of i is updating. So infinite loop will be created.
Correction: At last line i- should be changed as i–;

Is This Answer Correct ?    0 Yes 0 No

Question { 340 }

Write a C++ Program to Check Whether a character is Vowel or Consonant.


Answer

Solution:
/* C++ Program to Check Whether a character is Vowel or Consonant */
#include
using namespace std;
int main()
{
char c;
int isLowercaseVowel, isUppercaseVowel;
cout << "Enter any character to check :: ";
cin >> c;
// evaluates to 1 (true) if c is a lowercase vowel
isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
// evaluates to 1 (true) if c is an uppercase vowel
isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
// evaluates to 1 (true) if either isLowercaseVowel or isUppercaseVowel is true
if (isLowercaseVowel || isUppercaseVowel)
{
cout<<"
The Entered Character [ "< ";
}
else
{
cout<<"
The Entered Character [ "< ";
}
return 0;
}
Output:
/* C++ Program to Check Whether a character is Vowel or Consonant */
Enter any character to check :: u
The Entered Character [ u ] is a Vowel.
Process returned 0

Is This Answer Correct ?    0 Yes 0 No

 [1]   2    Next