Wednesday 28 January 2015

Write a C++ program to show a function of a class showing concept of default arguments.


#include
using namespace std;
class value
{
public:
void show(char='h',int=5); //default arguments
};
void value::show(char y,int x)
{
int i;
for(i=1;i<=x;i++)
cout< cout<<"\n";
}
int main()
{
value a,b,c;
a.show();
//no arguments
b.show(87,2);
//one arguments
c.show('m',3);
//two arguments
}

Some facts about Static data members (in C++)


Static data members can be declared private and still can be accessed. Eg :
#include <iostream>
using namespace std;
class stat
{
private:
static int p;
public:
static int Get() { return p; }
};
int stat::p;
int main()
{
stat s;
cout << s.GetValue() << endl;
}

Static data members can be accessed in the same way by static member functions.

Tuesday 27 January 2015

Write a C++ program for a class which includes static variable.


#include < iostream>
using namespace std;
class stat
{static int count;
public:
int a;
void getdata()
{
cout<< "enter no";
cin>>a;
cout<< a;
count++;
}
void showdata()
{
cout<< "count is"<< count< <endl;
}};
int stat::count=0;
int main()
{int i;
stat a;
a.showdata();
for(i=0;i<4;i++)
{
a.getdata();
a.showdata();
}
}

An important detail to keep in mind when debugging or implementing a program using a static class member is that you cannot initialize the static class member inside of the class.

Sunday 25 January 2015

Write a c++ program to create the equivalent four-function calculator. The program should request the user to enter a number, an operator, and another number. It should then carry out the specified arithmetical operation: adding, multiplying, or dividing the two numbers. (It should use a switch statement to select the operation). Finally it should display the result. When it finishes the calculation, the program should ask if the user wants to do another calculation. The response can be ‘Y’ or ‘N’.


#include< iostream>
using namespace std;
class calc
{public:
void inp();
};
void calc::inp()
{ int a,b;
int o;
cout<< "1 for add,2 for subtract,3 for multiply, 4 for divide";
cin>>o;
if(o==1||o==2||o==3||o==4)
{
cout< < "enter 1st no";
cin>>a;
cout< < "enter 2nd no";
cin>>b;
switch(o)
{
case 1:
cout<< "addition is"< < a+b;
break;
case 2:
if(a>b){
cout< else
cout<< b<< "-"< < a<< "is"< < b-a;
break;
case 3:
cout<< "multiplication is"<< a*b;
break;
case 4:
cout<< a<< "/"<< b<< "is"< < a/b;
break;
}}
else
cout<<"your input is wrong, choose nos 1,2,,3,4";
}
int main()
{
calc c;
char ch;
do
{
c.inp();
cout<<"\nDo another (Y/N)? ";
cin>>ch;
}while ((ch=='y')||(ch=='Y'));
}

Friday 23 January 2015

A point on the 2-d can be represented by two numbers: an x co-ordinate and a y co- ordinate. For example (4,5) represents a point 4 units to the right of origin and 5 units up the origin. The sum of two points can be defined as a new point whose x co- ordinate is the sum of x co-ordinates of both points and same for y co-ordinates. Write a C++ program that uses a structure called point to model a point. Define three points, and have the user input values to two of them. Then set the third point equal to the sum of the other two and display the value of the new point.


#include<iostream>
using namespace std;
struct point
{
int x,y;
};
int main()
{ point p1,p2,p3;
cout<<"enter coordinates for p1";
cin>>p1.x>>p1.y;
cout<<"enter coordinates for p2";
cin>>p2.x>>p2.y;
p3.x=p1.x+p2.x;
p3.y=p1.y+p2.y;
cout<<"p3's x coordinate is " < cout<<"p3'y coordinate is " < return 0;
}

Write a C++ program for Raising a number n to a power p is same as multiplying n by itself p times. Write a function called power that takes a double value for n and an int value for p returns the result as double value. Use a default argument of 2 for p so that if this argument is omitted the number will be squared. Write the main function that gets the values from user the user to test the function.


#include <iostream>
using namespace std;
double power(double n,int p=2)
{
double x=1.0;
int i;
for (i=0;i x*=n;
return x;
}
int main()
{
double m,res;
int q;
char ch;
cout<<"Enter a number to be raised to a power: ";
cin>>m;
cout<<"Do you want to enter the power (Y/N): ";
cin>>ch;
if ((ch=='y')||(ch=='Y'))
{
cout<<"Enter the power to which the number "< cin>>q;
res=power(m,q);
}
else
res=power(m);
cout<<"The result is: "<<res;
}

Sunday 18 January 2015

So finally parents can control the cell phone uses by their child :P

So finally parents will be able to control the cell phone uses by their child. A new app for iOS devices has been developed. It lets parents to have control on the smartphone used by their kids. It is known as 'Ignore No More' app. The app cannot be disabled from the child device and the company claims that it is virtually impossible to be removed by the child. Parents just need to install the app on their phone as well as their child’s phone, tap their kid’s name and enter a four-digit code to lock their device. This means that if you find your kid spending way too much time on his/her smartphone, you could simply tell them that if they don't listen to you, you will lock their phones.

If your kid is away and you need his immediate attention, you could lock the phone until they call you back to get the password from you. It's important to note that the kid won't lose the ability to call for emergency services.

If a kid tries to deactivate the admin role for the app their phone will immediately lock and the parent will receive a warning via email. It is available for $5.99, the Ignore No More app lets multiple parents share the license via Apple Family Sharing.


Sunday 11 January 2015

Now whatsapp will be more interesting


Well all of you must be knowing about Android mobile messaging app WhatsApp which allows you to exchange messages without paying. Now android will include a new feature of voice calling in the application as soon as possible.
With the latest rumours even pulling the launch date even closer with some leaked images, this feature is set to increase the number of WhatsApp users by many times.
The Whatsapp update V.4.0.0 is not on the stores yet, it is under beta stage. It will be released to the stores officially. Anyway, the new Whatsapp update has the long awaited “Free Voice Calling” feature where you could make international FREE phone call!
There will be a new section for voice calls, separate from the application’s chat function. Nothing has changed on how to initiate a conversation with a friend, just like with chat messages; you can also open the app and find a contact you wish to call and with a single tap of a button, you’ll see the avatar of your contact and a call immediately initiate.
The new WhatsApp for voice calling will include a section where users can view their call logs grouped as received, dialled and missed. Pictures and shared messages will be visible from beneath each contact’s name.
Whatsapp has the highest used app in its messaging category, including Facebook’s Messenger.

Tuesday 6 January 2015

Do you want to avoid heart attack? See how!


Do you want to avoid heart attack? A 20-year study was conducted. It tracked the lifestyle habits of almost 70000 female nurses and found six behaviours that can reduce the risk of heart disease by 92%.
The US women least likely to have a heart attack engaged in two-and-a-half hours of moderate to vigorous exercise a week, did not smoke, watched television for seven hours or fewer a week and had a healthy weight, equal to a body mass index of between 18 and 25.
Happily, women who had small amounts of alcohol - about a drink a day - did better than those who did not drink. Too much alcohol was a risk factor for developing heart diseases.
Women who did not get heart attacks or develop diabetes ate a healthy diet similar to the "healthy eating pyramid" designed by Harvard University's school of public health nutrition programme.
The Harvard diet recommends eating very little red and processed meat, and having small amounts of sugar, sugary drinks and salt.
White bread, rice, pasta and potatoes should be eaten in limited quantities. The staple foods of the diet are vegetables, fruit and high-fibre whole grains such as brown rice and oats.
Cheese, low-fat dairy and poultry and fish are also recommended.
"Mortality rates from heart disease in the US have been in decline for the last four decades, but women aged 35 to 44 have not experienced the same reduction," said Andrea K Chomistek, the study's lead author and a researcher at Indiana University in the US.
After two decades of research, scientists concluded that three-quarters of heart attacks could be prevented if women lived healthily.
Over the 20 years, 456 of the 70000 women had heart attacks.
But 31691 were diagnosed with a risk factor for heart disease including diabetes, high blood pressure and high LDL cholesterol.
Women with risk factors could prevent heart attacks by following at least four of the six lifestyle factors, the study said.
The average age at which heart attacks occurred was 50.

Best Facebook and Whatsapp Statuses ever


One of daily tasks of today's generation is changing Whatsapp Status and updating on FB. But it takes a lot of time to think about status which matches our mood and I think we all are bored of regular statuses. So here I am providing a list of some new statuses :
Senti Statuses(in hindi) :


1) Tumne maangi dua hume mile har khushi jab tum hi meri khushi to fir kiun mile naa !
2) Tumne keh to dia yaad karna nahii khwaab me tum bhi aana nahi !
3) jaane mene tumhe koi dhokha dia ya jaane tumhe koi dhokha hua
4) dhundne ko zamaane se wafaa nikla, pta chala leke galat ptaa nikla
5) milega na tujh jeha koi or
6) ik aah to bhari hogii humne naa suni hogi tumne jaate-2 ik awaaz to di hogii
7) tu gal sunda v nae tu rukda vi nae, ve me kinjh tenu smjhavan
8) tu mere to judaa kacchh wargi hawaa childi sahaan nu
9) Tu thodi der hor ther jaa
10) tere jaan daa dard hah badaa
11) tune jo na kahaa me wo suntaa rahaa
12) haath choote to rishte nahi toota karte
13) tasveer dekhta hun roz me tumhari kiya tumko bhi kabhii yun mera khyaal aaya
14) maudat hui hah na yaar ka koi haal aaya
15) tere pyaar me tere bin asa bhi saal aaya
16) jitne bhi khat likhe the shikwe shikayton ke me aaj subh ko tere darwaze daal aaya
17) yaad kiya dil ne kahaan ho tum
18) jaagte-2 ik umar katii ho jasa

Happy Status :

1) tohfa hai tera ye meri adaa
2) ye bandhan hai pyaar ka dekho toote na saajna
3) ye haseen vadiyaan ye khula aasmaan
4) kitni khoobsurat hain aankhein tumhaari banaa dijiye inhe kismat hamaari !