Skip to main content

Posts

Sample C++ Program To Calculate Final Velocity.

This is a sample C++ Program to calculate final velocity when time, acceleration and initial velocity are given. #include <iostream.h> #include <conio.h> void main() {     clrscr();     int v,u,a,t;     cout << "Enter The Velocity, Acceleration, Time: " << endl;     cin>>u>>a>>t;     v=u+a*t;     cout << "The Final Velocity Is " << v << "." << endl;     getch(); } OUTPUT: Enter The Velocity, Acceleration, Time: 0 5 2 The Final Velocity Is 10. ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & Print The User’s Age. --  C++ Program To Print A String. --  C++ Program To Accept & Display A Number. --  C++ Program To Print Sum Of Two Values. --  C++ Program To Print Square Of A Numeric Value. --  C++ Program To Accept & Print Marks & Find Total. --  C++ Progr...

C++ Program To Find Area Of The Triangle Using Heron's Formula.

This is a sample C++ program to find the area of a triangle using Heron's Formula. #include <iostream.h> #include <conio.h> #include <math.h> void main() {     double s1, s2, s3, ar, s;     cout<< " Enter 3 Sides : ";     cin >> s1 >> s2 >> s3;     s = (s1+s2+s3)/2;     ar = sqrt( s * ( s - s1) * (s - s2) * (s - s3));     cout << "\n The Area Of The Triangle = " << ar;     getch(); } OUTPUT: Enter 3 sides : 2 2 2 The Area of the triangle = 1.732051 ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & Print The User’s Age. --  C++ Program To Print A String. --  C++ Program To Accept & Display A Number. --  C++ Program To Print Sum Of Two Values. --  C++ Program To Print Square Of A Numeric Value. --  C++ Program To Accept & Print Marks & Find Total. --  C++ Progra...

C++ Program To Find Sum & Average Of Two Numbers.

This is a sample C++ program to accept two numbers & find it's sum and average. #include <iostream.h> #include <conio.h> void main() {     clrscr();     int x, y, sum;     float average;     cout << " Enter 2 Integers : " << endl;     cin>>x>>y;     sum=x+y;     average=sum/2;     cout << " The Sum Of " << x << " & " << y << " Is " << sum << "." << endl;     cout << " The Average Of " << x << " & " << y << " Is " <<  average << "." << endl;     getch(); } OUTPUT: Enter 2 Integers : 20 40 The Sum Of 20 & 40 Is 60. The Average Of 20 & 40 Is 30. ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & Print The User’s Age. --  C++ Program To Print A String. --  C++...

Sample C++ Program To Accept A Number ‘n’ & Find Sum Of All Numbers Upto 'n' - 15.

This program accepts a number from the user and finds the sum of all the numbers up to the number entered by the user. SAMPLE PROGRAM: #include <iostream.h> #include <conio.h> int recursion(int num); int main() { int num = 0; int sumnum; cout << "Enter any integer greater than 0: " << endl; cin >> num; sumnum = recursion(num); cout << "The sum is: " << sumnum << endl; cin.ignore(); cin.get(); return 0; } int recursion(int num) { int sum = 0; if(num == 1) return 1; else   {     sum = recursion(num - 1) + num;     return sum;   } } OUTPUT: Enter any integer greater than 0: 6 The sum is: 21 ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & Print The User’s Age. --  C++ Program To Print A String. --  C++ Program To Accept & Display A Number. --  C++ Program To Print Sum Of Two Values. --  C++ Program To Print S...

Sample C++ Program To Calculate The Greatest Common Divisor Of Two Numbers - 14.

This program accepts two numbers from the user and finds out the greatest common divisor of the two numbers. SAMPLE PROGRAM: #include <iostream.h> #include <conio.h> int GCD(int a, int b) { int remainder; while( b != 0 )   {     remainder = a % b;     a = b;     b = remainder;   } return a; } int main() { int x, y; cout << "To find the greatest common divisor, enter the values specified below \n"; cout << "Value 1: "; cin >> x; cout << "Value 2: "; cin >> y; cout << "\nThe Greatest Common Divisor of " << x << " and " << y << " is " << GCD(x, y) << endl; return 0; } OUTPUT: To find the greatest common divisor, enter the values specified below Value 1: 20 Value 2: 10 The Greatest Common Divisor of 20 and 10 is 10 ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & ...

Sample C++ Program To Find The Square Root Of A Number - 13

This program helps to find out the square root of the number entered by the user. SAMPLE PROGRAM: #include <iostream.h> #include <conio.h> #include <math.h> int main() { clrscr(); int x; cout << "Enter a number "; cin >> x; double y = sqrt(x); cout << "The square root of " << x << " is " << y << endl; x++; return 0; } OUTPUT: Enter a number 4 The square root of 4 is 2 ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & Print The User’s Age. --  C++ Program To Print A String. --  C++ Program To Accept & Display A Number. --  C++ Program To Print Sum Of Two Values. --  C++ Program To Print Square Of A Numeric Value. --  C++ Program To Accept & Print Marks & Find Total. --  C++ Program To Accept Three Numbers & Print Percentage Marks. --  C++ Program To Check Whether A Number Is Greater Than 100 Or Not. --...

Sample C++ Program To Calculate The Area Of A Rectangle - 12.

This program helps user to find the area of a rectangle. All the user has to do is enter the length and the breadth of the rectangle. SAMPLE PROGRAM: #include <iostream.h> #include <conio.h> int main() { float length; float width; float area; cout << "Enter length of rectangle: "; cin >> length; cout << "Enter width: "; cin >> width; area = length * width; cout << "\nArea of rectangle is: " << area << endl; return 0; } OUTPUT: Enter length of rectangle: 4 Enter width: 3 Area of rectangle is: 12 ALSO CHECK THE FOLLOWING C++ PROGRAMS: --  C++ Program To Accept & Print The User’s Age. --  C++ Program To Print A String. --  C++ Program To Accept & Display A Number. --  C++ Program To Print Sum Of Two Values. --  C++ Program To Print Square Of A Numeric Value. --  C++ Program To Accept & Print Marks & Find Total. --  C++ Program To Accep...