13)
The output is 7(::p) + 90 (p) - 5.5(var) = 91.5
14)
7 times
from 0-9 there are 10 numbers out of which # will not be printed for 2,4,6 hence # will be printed for 10-3 = 7 numbers.
15)
a. double pow(double x,double y)
The pow() function takes ‘double’ as the arguments and returns a ‘double’ value.
b. T floor(T x) where T can be double,float,long double.
The floor() function takes a single argument and returns a value of type double, float or long double type.
16)
a. False, isupper retruns an int value
b. False, for loop is pre-test loop(test expression is evaluated before running the body of the loop) whereas do-while loop is a post-test loop(test expression is evaluated after executing the body of the loop)
c. False
Consider the following:
if(var < 100)
{
if(var <50)
{
cout << "Less than 50" << endl;
}
}
else
{
cout << "Greater than 100" << endl;
}
In this else is paird with if(var < 100) and not with if(var < 50).
d. True, bool stores either true or false.
e. True
program. 13. What's the output of the following program? #include< iostream> #include&math> using namespace std; int...
Need a FLOW Chart for that code. #include <iostream > using namespace std; int PowerFive(int); //Function prototype declaration int main() for (int i=-10 ; i(z10; 1++) {//for each # cout<<"("<< ǐ<<") ^5. "<<PowerFive(1)くくendl;// calling the defined Function int PowerFive (int a) //Function definition return a*a*a*a*a;
#include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...
Give the output of the following C++ program and explain your reasoning: #include <iostream> using namespace std; int gcd( int , int ); //Function prototype int main() { int a = 105; int b = 30; cout << “The GCD of “ << a << “ and “ << b << “ is “ << gcd(a,b) << endl; return 0; } int gcd(int a, int b) { if ( b == 0 ) return a; else return gcd(b,a%b); }
#include "stdafx.h" #include <iostream> using namespace std; class dateType { private: int dmonth; int dday; int dyear; public: void setdate (int month, int day, int year); int getday()const; int getmonth()const; int getyear()const; int printdate()const; bool isleapyear(int year); dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) { int numofdays; if (year<=2008) { dyear=year;...
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
Write the missing statements for the following program. #include <iostream> using namespace std; int main(void) { int Num1; cout << "Enter 2 numbers: "; cin >> Num2; if (Num1 < Num2) cout << "Smallest number is " << Num1; else cout << "Smallest number is " << Num2; return 0; }
#include <iostream> using namespace std; - // Guess the output for the below program. // Assume address of a,b,c as 4004, 4008, 4016 respectively. int main() { float a = 12.5; int b = 10; double c = 3.1412; float aptr = &a; int *bptr = &b; double *cptr = &c; cout << "value of variable a,b,c:"<< a <<""<<b<<""<<<<<endl; cout << "Address of variable a,b,c:"<<&a<<""<<&b<<""<<&c << endl; cout << "value of aptr, bptr, cptr:" << aptr <<""<<bptr <<"" << cptr...
Fix this code so only the function prototype comes before main. #include <iostream> using namespace std; bool isMultiple(int num1, int num2) { return num1 % num2 == 0; } int main() { char ch = 'Y'; int num1, num2; while(ch =='Y') // While ch is equal to Y { cout << "Enter two numbers(largest first): "; cin >> num1; // Getting 1st number cin >> num2; // Getting 2nd number if(isMultiple(num1, num2)) cout << num2 << " " << "IS...
What is the output of this program? #include <iostream> using namespace std; class rect { int x, y; public: void val (int, int); int area () { return (x * y); } }; void rect::val (int a, int b) { x = a; y = b; } int main () { rect rect; rect.val (3, 4); cout << "rect area: " << rect.area(); return 0; } a) rect area:7 b) rect area: 12 c) rect area:24 d) none of the...
Watermelon Problem: The answer should not include any whitespace. #include<iostream> using namespace std; int main() { double distance, gravity =9.8, height; int time, t=0; cout<<"Please input the time of fall in seconds:"<<endl; [ A ] // Get the user input of the time of fall in seconds (Use cin>> method) cout<<endl; cout<<"Please input the height of the bridge in meters:"<<endl; [ B ] // Get the user input of the height of the bridge in meters (Use cin>>...