Programs of Cpp-Language
C++ language
Program # 1
Hello World!
Program # 2
Sum of Characters
Program # 3
Use of Comments
Program # 4
Use of Increment Operator
Program # 5
Print Area of Square
Program # 6
Sum of two floating numbers
Program # 7
Use of Escape sequence
Program # 8
Convert Kilometers into Meters
Program # 9
Maximum between 3 numbers
Program # 10
The number is negative, positive, or zero.
#include <iostream>using namespace std;int main(){ int a; cout<<"Please enter a number\n"; cin>>a; if(a == 0) { cout<<a<< " is Zero"; } else if (a > 0) { cout<<a<<" is the positive number"; } else if (a < 0) { cout<<a<<" is the negative number"; } else { cout<<"Please Enter the Number"; } return 0; }
Program # 11
Number is Even or Odd.
#include <iostream>using namespace std;int main(){ int num; cout<<"Please enter a numbers\n"; cin>>num; if(num % 2 == 0) { cout<<num<<" is an Even number"; } else if (! num % 2 == 0) { cout<<num<<" is an Od number"; } else { cout<<"Please Enter the valid Number"; } return 0; }
Program # 12
Year is leap or not
#include <iostream>using namespace std;int main(){ int year; cout<<"Please enter a year\n"; cin>>year; if(year % 4 == 0) { cout<<year<<" is leap year"; } else { cout<<year<<" is not a leap year"; } Return 0; }
Program # 13
Find Factorial of any Number
Program # 14
Enter the day number to print the day name
Program # 15
#include <climits>
#include <iostream>
using namespace std;
int main()
{
// int maxNum=INT_MIN;
//int minNum=INT_MAX;
int maxNum=0;
int minNum=1100;
int n,m;
string student[n],maxNums,minNums;
cout<<"Please enter the total numbers of students: ";
cin>>n;
m=n;
int marks[m],Total_marks,percentage;
cout<<"\nPlease enter the Total Marks: ";
cin>>Total_marks;
for(int i=0;i<n;i++)
{
cout<<"\nPlease enter Students name: ";
cin>>student[n];
cout<<"\nObtained marks: \n";
cin>>marks[m];
percentage= marks[m]*0.1;
if(percentage>33)
{
cout<<"Student: "<<student[n]<<" has passed the exams with marks: "<<marks[m];
} else {
cout<<"Student: "<<student[n]<<" has failed the exams with marks: "<<marks[m];
}
for(int i =0;i<=n;i++)
{
if(marks[m]>maxNum)
{
maxNum=marks[m];
maxNums= student[n];
} if(marks[m]< minNum)
{
minNum=marks[m];
minNums=student[n];
}
}} cout<<"\nThe Highest Marks are: "<<maxNum<<" of Student: "<<maxNums;
cout<<"\nThe Lowest Marks are: "<<minNum<<" of Student: "<<minNums;
return 0;
}
0 Comments