Thursday, 27 April 2017
Tuesday, 25 April 2017
Friday, 24 June 2016
C++ Program - Swapping Two Integers
#include
using namespace std;
int main() {
int number1,number2;
cout<<"Enter 1st No. ";
cin>>number1;
cout<<"Enter 2nd NO ";
cin>>number2;
cout<<"Before Swapping ";
cout< number1 = number1 + number2;
number2 = number1 - number2;
number1 = number1 - number2;
cout<<"After Swapping ";
cout< return 0;
}
using namespace std;
int main() {
int number1,number2;
cout<<"Enter 1st No. ";
cin>>number1;
cout<<"Enter 2nd NO ";
cin>>number2;
cout<<"Before Swapping ";
cout<
number2 = number1 - number2;
number1 = number1 - number2;
cout<<"After Swapping ";
cout<
}
C++ Program - To find Leap Year or Not
#include
using namespace std;
int main() {
int year;
cout << "Enter a year: ";
cin >> year;
if (year%4 == 0) {
if (year%100 == 0) {
if (year%400 == 0) {
cout << year << " is a leap year.";
} else {
cout << year << " is not a leap year.";
}
} else {
cout << year << " is a leap year.";
}
} else {
cout << year << " is not a leap year.";
}
return 0;
}
using namespace std;
int main() {
int year;
cout << "Enter a year: ";
cin >> year;
if (year%4 == 0) {
if (year%100 == 0) {
if (year%400 == 0) {
cout << year << " is a leap year.";
} else {
cout << year << " is not a leap year.";
}
} else {
cout << year << " is a leap year.";
}
} else {
cout << year << " is not a leap year.";
}
return 0;
}
C++ Program - Largest Number in an Array
#include
#include
#include
using namespace std;
int main() {
int i,j,temp,arrSize;
cout<<"Enter Array Size.:";
cin>>arrSize;
int a[arrSize];
cout<<"Enter Any"< for(i=0;i cin>>a[i];
}
for(i=0;i for(j=i+1;j if(a[j] < a[i]) {
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
cout<<"Largest No. is "< return 0;
}
#include
#include
using namespace std;
int main() {
int i,j,temp,arrSize;
cout<<"Enter Array Size.:";
cin>>arrSize;
int a[arrSize];
cout<<"Enter Any"<
}
for(i=0;i
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
cout<<"Largest No. is "< return 0;
}
C++ Program - Hollow Square Number Pattern
#include
using namespace std;
main() {
int squareWidth,limit,tempWidth = 0,i;
cout<< "Enter Widht: ";
cin>> squareWidth;
limit = (squareWidth-1)*4;
limit++;
for(int width=1; width<=squareWidth; width++) {
if(width <= 1)
for(i=1; i<=squareWidth; i++) {
tempWidth++;
cout<< tempWidth<<"\t";
}
else if(width cout<< endl;
for(i=1; i<=squareWidth; i++) {
if(i==1 || i==squareWidth)
if(i == 1) {
limit--;
cout< }
if(i == squareWidth) {
tempWidth++;
cout< }
else
cout<<"\t";
}
} else {
cout<< endl;
for(i=limit-1; i>tempWidth; i--) {
cout<< i<<"\t";
}
}
}
}
using namespace std;
main() {
int squareWidth,limit,tempWidth = 0,i;
cout<< "Enter Widht: ";
cin>> squareWidth;
limit = (squareWidth-1)*4;
limit++;
for(int width=1; width<=squareWidth; width++) {
if(width <= 1)
for(i=1; i<=squareWidth; i++) {
tempWidth++;
cout<< tempWidth<<"\t";
}
else if(width
for(i=1; i<=squareWidth; i++) {
if(i==1 || i==squareWidth)
if(i == 1) {
limit--;
cout<
if(i == squareWidth) {
tempWidth++;
cout<
else
cout<<"\t";
}
} else {
cout<< endl;
for(i=limit-1; i>tempWidth; i--) {
cout<< i<<"\t";
}
}
}
}
Subscribe to:
Posts (Atom)
CakePHP Date Picker
Folder Structure: Controller: File location - cakephp/src/controller/HomepageController.php namespace App\Controller; use...
-
Introduction: Java in an object-oriented, multi-threaded programming languag...
-
Polymorphism (from Greek, meaning “many forms”) is the quality that allows one interface to access a general class of actions. The speci...