Professional Documents
Culture Documents
Program
Program
#include <iostream>
using namespace std;
int main()
{
float Kilometer, Meter;
cout << "Value in KM =\n" << endl;
cin >> Kilometer;
Meter = Kilometer*1000.0;
cout << Kilometer << "Kilometer = " << Meter << "meter" << endl;
system("pause");
return 0;
}
Program 2:
#include<iostream>
using namespace std;
int main()
{
char name [6], gender[6];
int age, id;
cout << "Name of the student:";
cin >> name;
cout << "Gender of the student:";
cin >> gender;
cout << "Age of the student:";
cin >> age;
cout << "ID of the student:";
cin >> id;
cout << "\nName of the student:" << name << endl;
cout << "Gender of student:" << gender << endl;
cout << "Age of the student:" << age << endl;
cout << "ID of the student:" << id << endl;
system("pause");
return 0;
}
Program 3:
#include<iostream>
using namespace std;
int main()
{
int petrol, distance;
cout << "Enter petrol in liters : ";
cin >> petrol;
distance = 5.3 * petrol;
cout << "Distance : " << distance << " miles." << endl;
system("pause");
return 0;
}
Program 4:
#include <iostream>
using namespace std;
int main() {
char c;
cout << "Enter a character: ";
cin >> c;
cout << "ASCII Value of " << c << " is " << int(c) << endl;
system("pause");
return 0;
}
Program 5:
#include<iostream>
#include <iostream>
using namespace std;
int main() {
float num1, num2, sum;
cout << "Enter Two Numbers\n";
cin >> num1 >> num2;
sum = num1 + num2;
cout << "Sum of " << num1 << " and " << num2 << " is = " << sum << endl;
system("pause");
return 0;
}
Program 7:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float a, b, c, s, area;
cout << "Enter Length of Three Sides (one by one): ";
cin >> a >> b >> c;
s = (a + b + c) / 2;
area = sqrt(s*(s - a)*(s - b)*(s - c));
cout << "\nArea = " << area;
cout << endl;
system("pause");
return 0;
}
Program 8:
#include <iostream>
using namespace std;
int main()
{
int percentage, n1, n2;
n1 = 35;
n2 = 6000;
percentage = (n1 / 100) * 6000;
cout << percentage << endl;
system("pause");
return 0;
}
Program 9:
#include <iostream>
using namespace std;
int main()
{
double sum, avg, s1, s2, s3;
cout << "Enter Marks of s1, s2, s3 =" << endl;
cin >> s1 >> s2 >> s3;
sum = s1 + s2 + s3;
cout << "Total Marks =" << sum << endl;
avg = sum / 3;
cout << "Average of Marks =" << avg << endl;
system("pause");
return 0;
Program 10:
#include <iostream>
using namespace std;
int main()
{
cout << "\n Print the following pattern:\n";
cout << " *****\n";
cout << " ****\n";
cout << " ***\n";
cout << " **\n";
cout << " *\n";
cout << "******\n";
cout << "******\n";
cout << "******\n";
cout << "******\n";
cout << "******\n";
cout << "******\n";
system("pause");
return 0;
}
Program 11:
#include<iostream>
using namespace std;
int main()
{
int n, sum = 0;
cout << "EnterNumber = "<<endl;
cin >> n;
while (n>0)
{
sum += n;
n--;
}
cout << "sum is:" << sum<<endl;
system("pause");
return 0;
}