1. C++ program to find the sum and average of one dimensional integer array

#include<iostream> using namespace std; int main() { int n; cout<<“Enter Number of elements you want to enter :: “; cin>>n; float arr1[n],sum=0,avg; for(int i = 0;i<n;i++){ cin>>arr1[i]; sum = sum + arr1[i]; } for(int i = 0;i<n;i++) cout<<arr1[i]<<“\t”; avg= sum/5; cout<<“\nSum =”<<sum<<“\nPercentage = “<<avg; return 0; }

5. C++ Program to Check whether a year is Leap year or not

#include<iostream> using namespace std; int main() { int year; cout<>year; if(year%100==0) { if(year%400==0) cout<<"Leap Year"; } else if(year%4==0) cout<<"Leap Year"; else cout< using namespace std; int main() { int year; cout<>year; if((year%100==0 && year%400==0)|| (year%4==0)) cout<<"Leap Year"; else cout<<"Not a Leap Year"; return 0; }

3. C++ Program to find Greatest number among three numbers

#include<iostream> using namespace std; int main() { int num1, num2, num3; cout<>num1>>num2>>num3; if(num1>num2){ if(num1>num3) cout<<num1<<" is greatest"; else cout<<num3<num3) cout<<num2<<" is greatest"; else cout<<num3<<" is greatest"; return 0; }

9. C++ program to swap two numbers using macros

#include<iostream> #define SWAP(a,b) {int temp; temp=a; a=b; b=temp;} using namespace std; int main() { int x,y; cout<<“Enter two numbers :: “; cin>>x>>y; SWAP(x,y); cout<<“x= “<<x<<” y= “<<y; return 0; }

8. C++ program to swap two numbers without using temp variable

#include<iostream> using namespace std; int main() { int a, b; cout<<“Enter Two numbers”; cin>>a>>b; a = a + b; b = a – b; a = a – b; cout<<“Swapped values ::\n”; cout<<a<< ” “<<b; return 0; } or #include<iostream> using namespace std; int main() { int a, b; cout<<“Enter Two numbers”; cin>>a>>b; a =…

7. C++ Program to Convert given no. of days into years, weeks and days

#include<iostream> using namespace std; int main() { int days, weeks, years; cout<<“Enter Total Days :: “; cin>>days; years = days /365; days %=365; weeks = days/7; days %=7; cout<<“Converted ::\n”; cout<<“years :: “<<years<<endl; cout<<“Weeks :: “<<weeks<<endl; cout<<“Days :: “<<days<<endl; return 0; }