Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
int main()
{
int count1 = 0, count2 = 0, num1, num2, call_hexadecimal,
call_octal, mod_remainder1[limit], remainder[limit],
mod_remainder2[limit]; // Declaring the variables
cout << "Enter a number: ";
cin >> num1;
num2 = num1;
cout << endl << endl;
cout << "Octal Equivalent: ";
{
cout << mod_remainder1[call_octal];
call_octal--;
}
// Printing Hexadecimal
{
if (mod_remainder2[call_hexadecimal] == 10)
{
cout << "A";
}
else if (mod_remainder2[call_hexadecimal] == 11)
{
cout << "B";
}
else if (mod_remainder2[call_hexadecimal] == 12)
{
cout << "C";
}
else if (mod_remainder2[call_hexadecimal] == 13)
{
cout << "D";
}
else if (mod_remainder2[call_hexadecimal] == 14)
{
cout << "E";
}
else if (mod_remainder2[call_hexadecimal] == 15)
{
cout << "F";
}
else
{
cout << mod_remainder2[call_hexadecimal];
}
call_hexadecimal--;
}
return 0;
}
Q.2:* http://www.cplusplus.com/reference/limits/numeric_limits/
Numeric limits type:It provides details about the properties of arithmetic
types integer and floating point both for which the library
compiles.
This class template is specialized for every arithmetic type,
with its members describing the properties. This template shall
not be specialized for any other type.
PROGRAM FOR BINARY EQUIVALENT NUMBERS:#include <iostream>
#include <limits>
{
mod_remainder[count] = num % 2;
num /= 2;
count++;
}
cout << num;
call_remainder = count - 1;
while (call_remainder >= 0)
{
cout << mod_remainder[call_remainder];
call_remainder--;
}
return 0;
}
http://www.cplusplus.com/reference/limits/numeric_limits/
Q.3:-
}
string result(word);//String variable(variable) converts array
return result;
}
int main()
{
string sentence,print;
cout<<"Enter the sentence: ";
getline(cin,sentence);
print=tocapital(sentence);
cout << endl << endl;
cout<<print;
return 0;
}
* http://www.ytpak.com/watch?v=XUmZcK44lsc
//Declaring limits
int
int num2,num1;
//Declaring variables
int occur[limit]={0,0,0,0,0,0};
srand(time(NULL));
cout<<"Enter the no of times you want to throw the dice: ";
cin>>num2;
for(int count=1; count<=num2; ++count)//Generating random nos.
{
num1 = (rand()%6)+1;
if(num1 == limit)
{
occur[0] = occur[0]+1;
}
if(num1 == limit-1)
{
occur[1] = occur[1]+1;
}
if(num1 == limit-2){
occur[2]=occur[2]+1;
}
if(num1 == limit-3){
occur[3]=occur[3]+1;
}
if(num1 == limit-4){
occur[4]=occur[4]+1;
}
if(num1 == limit-5)
{
occur[5]=occur[5]+1;
}
}
cout << "Result:" << endl;
cout << "1 appeared: " << occur[5] << "times" << endl;
cout << "2 appeared: " << occur[4] << "times" << endl;
cout << "3 appeared: " << occur[3] << "times" << endl;
cout << "4 appeared: " << occur[2] << "times" << endl;
cout << "5 appeared: " << occur[1] << "times" << endl;
cout << "6 appeared: " << occur[0] << "times" << endl;
return 0;
}
*http://www.ytpak.com/watch?v=naXUIEAIt4U