0% found this document useful (0 votes)
1 views11 pages

Programming Sheet

The document contains a series of programming questions and code snippets primarily in C++. It covers topics such as variable declarations, basic arithmetic operations, user input, and output formatting. The examples illustrate fundamental programming concepts and syntax.

Uploaded by

mohamed khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views11 pages

Programming Sheet

The document contains a series of programming questions and code snippets primarily in C++. It covers topics such as variable declarations, basic arithmetic operations, user input, and output formatting. The examples illustrate fundamental programming concepts and syntax.

Uploaded by

mohamed khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Programming sheet

‫حماده نصر جاد‬

Q1
1- int feet = 0, inches = 0;
2- int feet(0), inches(0);

Q2
int count = 0;
double distance = 1.5;

Q3
sum = n1 + n2;

Q4
length += 8.3;
Q5
product = n * n;

Q6

#include <iostream>
using namespace std;

int main() {
int a, b, c, d, e, f; // declared but not
initialized
cout << a + b + c + d + e + f << endl;
return 0;
}
Q7
a: carSpeed
b: hourlyPayRate
c: highestExamScore

Q8
cout << "The answer to the question of\
nLife, the Universe, and Everything is 42."
<< endl;

Q9
cout << "Enter a whole number: ";
cin >> _number;
Q10
cout << fixed << setprecision(3);

Q11

#include <iostream>
using namespace std;

int main() {
cout << "Hello world";
return 0;
}
Q12
#include <iostream>
using namespace std;

int main() {
int num1, num2;
cout << "Enter two numbers: ";
cin >> num1 >> num2;
cout << "The sum is: " << num1 + num2
<< endl;
return 0;
}

Q13
#include <iostream>
using namespace std;
int main() {
int num1, num2;
cout << "Enter two numbers: ";
cin >> num1 >> num2;
cout << "The sum is: " << num1 + num2
<< endl;
return 0;
}

Q14
#include <iostream>
#include <iomanip> // For formatting
output

using namespace std;


int main() {
double one = 1.000, two = 1.414, three =
1.732, four = 2.000, five = 2.236;

cout << "N\tSquare Root" << endl;


cout << "1\t" << one << endl;
cout << "2\t" << two << endl;
cout << "3\t" << three << endl;
cout << "4\t" << four << endl;
cout << "5\t" << five << endl;

return 0;
}
Q15
3*x

→3*x+y

→ (x + y) / 7

→ (3 * x + y) / (z + 2)

Q16
a = 'b';
b = 'c';
c = a;
cout << a << b << c << 'c';
Q16
a = 'b';
b = 'c';
c = a;
cout << a << b << c << 'c';

Q17
int number = (1 / 3) * 3;
cout << "(1/3) * 3 is equal to " << number;

Q18
#include <iostream>
using namespace std;

int main() {
int num1, num2;
cout << "Enter two numbers: ";
cin >> num1 >> num2;

int wholePart = num1 / num2;


int remainder = num1 % num2;

cout << "Whole part: " << wholePart <<


endl;
cout << "Remainder: " << remainder <<
endl;

return 0;
}

You might also like