SWAPPING NUMBERS USING 6 METHODS: FIRST METHOD: // C++ program to swap numbers using temporary variable INPUT: #include<iostream> using namespace std; int main() { int x,y,z; cout<<"Enter The Value of x : "; cin>>x; cout<<"Enter The Value of y : "; cin>>y; cout<<"\n\t Before Swapping"<<endl; cout<<"x = "<<x<<endl; cout<<"y = "<<y<<endl; z=x; x=y; y=z; cout<<"\n\t After Swapping"<<endl; cout<<"x = "<<x<<endl; cout<<"y = "<<y<<endl; return 0; } SECOND METHOD: // C++ program to swap numbers without using Temporary variables using addition and subtraction operator INPUT: #include<iostream> using namespace std; int main() { int x,y; ...
Introduction to fundamental Data types: Fundamental data types are predefined data types available with C++.There are five fundamental data types in C++: - char - int - float - double - void...
// C++ program to check if a year is leap year or not INPUT: #include<iostream> using namespace std; int main() { int z; cout<<"Enter a year:"; cin>>z; if(z%4==0){ if(z%100==0){ if(z%400==0) cout<<"\n\t"<<z<<" is a leap year"; else cout<<"\n\t"<<z<<" is not a leap year"; } else cout<<"\n\t"<<z<<" is a leap year"; } else cout<<"\n\t"<<z<<" is not a leap year"; return 0; } OUTPUT:
Comments
Post a Comment