Part - 01 - Basic C++ Exercises - C++ Basic Exercises - Saylor Academy - Saylor Academy
Part - 01 - Basic C++ Exercises - C++ Basic Exercises - Saylor Academy - Saylor Academy
Write a program in C�� to print the sum of two numbers using variables.
Print the sum of two numbers :
-----------------------------------
The sum of 29 and 30 is : 59
Write a program in C�� to check the upper and lower limits of integer.
Expected Output:
Check the upper and lower limits of integer :
--------------------------------------------------
The maximum limit of int data type : 2147483647
The minimum limit of int data type : -2147483648
The maximum limit of unsigned int data type : 4294967295
The maximum limit of long long data type : 9223372036854775807
The minimum limit of long long data type : -9223372036854775808
The maximum limit of unsigned long long data type : 18446744073709551615
The Bits contain in char data type : 8
The maximum limit of char data type : 127
The minimum limit of char data type : -128
The maximum limit of signed char data type : 127
The minimum limit of signed char data type : -128
The maximum limit of unsigned char data type : 255
The minimum limit of short data type : -32768
The maximum limit of short data type : 32767
The maximum limit of unsigned short data type : 65535
Write a program in C�� to check whether the primitive values crossing the limits or not.
Check whether the primitive values crossing the limits or not :
--------------------------------------------------------------------
Help
The Gender is : F
Is she married? � 1
Number of sons she has : 2
Year of her appointment : 2009
Salary for a year : 1500000
Height is : 79.48
GPA is 4.69
Salary drawn upto : 12047235
Balance till : 995324987
Write a program in C�� to display various type or arithmetic operation using mixed data type.
Sample output:
Write a program in C�� to display the operation of pre and post increment and decrement.
Sample Output:
Display the operation of pre and post increment and decrement :
--------------------------------------------------------------------
The number is : 57
After post increment by 1 the number is : 58
After pre increment by 1 the number is : 59
After increasing by 1 the number is : 60
After post decrement by 1 the number is : 59
After pre decrement by 1 the number is : 58
After decreasing by 1 the number is : 57
Print the result of some specific operation :
--------------------------------------------------
Result of 1st expression is : 23
Result of 2nd expression is : 5
Result of 3rd expression is : 12
Result of 4th expression is : 3
Write a program in C�� to find the area of any triangle using Heron's Formula.
Sample Output:
Find the area of any triangle using Heron's Formula :
----------------------------------------------------------
Input the length of 1st side of the triangle : 5
Input the length of 2nd side of the triangle : 5
Input the length of 3rd side of the triangle : 5
The area of the triangle is : 10.8253
Write a program in C�� that converts kilometers per hour to miles per hour.
Sample Output:
Convert kilometers
per hour to miles per hour :
----------------------------------------------------
Input the distance in kilometer : 25
The 25 Km./hr. means 15.5343 Miles/hr.
Write a program in C�� to compute the total and average of four numbers.
Sample Output:
Compute the total and average of four numbers :
----------------------------------------------------
Input 1st two numbers (separated by space) : 25 20
Input last two numbers (separated by space) : 15 25
The total of four numbers is : 85
The average of four numbers is : 21.25
Write a program in C�� to input a single digit number and print a rectangular form of 4 columns and 6 rows.
Sample Output:
Make a rectangular shape by a single digit number :
--------------------------------------------------------
Input the number : 5
5555
5 5
5 5
5 5
5 5
5555
Write a program in C�� to divide two numbers and print on the screen.
Sample Output:
Divide two numbers and print:
----------------------------------
The quotient of 30 and 10 is : 3
Display the Current Date and Time :
----------------------------------------
seconds = 57
minutes = 33
hours = 12
day of month = 6
month of year = 7
year = 2017
weekday = 4
day of year = 186
daylight savings = 0
Current Date: 6/7/2017
Current Time: 12:33:57
Write a program in C�� to compute the specified expressions and print the output.
Sample Output:
Compute the specified expressions and print the output:
------------------------------------------------------------
Result of the expression (25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5) is : 2.13889
Policies
Powered by Moodle
© Saylor Academy 2010�2024 except as otherwise noted. Excluding course final exams, content authored by Saylor Academy is available under a
Creative Commons Attribution 3.0 Unported license . Third-party materials are the copyright of their respective owners and shared under various
licenses. See detailed licensing information. Saylor Academy®, Saylor.org®, and Harnessing Technology to Make Education Free® are trade names
of the Constitution Foundation, a 501(c)(3) organization through which our educational activities are conducted.
b ~ y
Privacy Policy