Wednesday 31 December 2014

SUICIDE IS INHERITABLE

A  study says that children whose parents attempted suicide are 5 times more likely to attempt suicide than another children which means suicide is also inherited.
 “In this high-risk longitudinal study, we found that parental suicide attempt conveyed a nearly 5-fold increased risk of offspring attempt, even controlling for the familial transmission of mood disorder,” explains lead study author David A Brent MD, of the University of Pittsburgh Medical Centre.
But the study not only confirmed suicidal behaviour can in fact run in families, but that these pathways for suicidal behaviour can be transmitted through families, almost pathologically.
Impulsive aggression played an important role in increasing the likelihood of an offspring suicide attempt, but it did so by increasing the risk of the subsequent development of a mood disorder, which in turn increased the risk of an attempt.

In this study, the researchers looked at 701 children (between the ages of 10 and 50) of 334 parents who had documented mood disorders. 191 of these parents had attempted suicide, and 44 percent of the offspring had followed suit before the study; 29 percent attempted suicide after during the study follow-up.

Tuesday 30 December 2014

Write a C++ program to check whether a number is even or odd


#include
using namespace std;
int main()
{
int a;
cout<<"enter no";
cin>>a;
if(a%2==0)
{
cout<<"no is even"< }
else
{ cout<<"no is odd"< }
}

Write a C++ to find greatest of three numbers.


#include<iostream>
using namespace std;
int sum(int x,int y,int z)
{
if(x>y)
{ if(y>z)
{
return x;
}}
if(y>z)
{
return y;
}

else{ return z;
}
}
int main()
{ int a=0,b=0,c=0;
cout<<"enter first no";
cin>>a;
cout<<"enter second no";
cin>>b;
cout<<"enter third no";
cin>>c;
int d= sum(a,b,c);
cout<<"greatest is "< }

Sunday 28 December 2014

Write a c++ program to find Simple Interest and Compound Interest.



#include<cmath>
#include<iostream>
using namespace std;
double simple(int p,float r,int t)
{
return (p*r*t)/100;
}
double amount(int p,float x,int y,float z)
{ x= 1+z/100;
return p*pow(x,y);
}
double compound(int c,int d) {
return c-d;
}
int main()
{ int p=0,t=0;
float r;
double s = simple(200,1.2,2);
double d = amount(200,1.2,2,2.4);
double ci = compound(d,p);
}


Things to learn :

include<cmath> is used in place of include<math.h>
include<cmath>h is used in gcc compiler (in linux)

pow() is an inbuilt function in c++ with syntax :
double pow (double base, double exponent);

Write a c++ program to find the sum of two numbers using function.


#include<iostream>
using namespace std;
int sum(int a,int b)
{ return a+b;
}
int main()
{
int a=0,b=0;
cout<<"enter 1st no";
cin>>a;
cout<<"enter 2nd no";
cin>>b;
int c = sum(a,b);
}

Things to learn from this program :

Defining a Function:

function definition :

return_type function_name( parameter list )
{
body of the function
}

Declaring a Function:

return_type function_name(parameter list);

Calling a function :

function_name( [arg1, ... ] );

Function is to be defined outside main() function.
a and b are to be initialized to zero so that all previous values are deleted.


Another way of doing the program (if you want to do sum of known values):



#include<iostream>
using namespace std;
int sum(int a,int b){
return a+b;
}
int main()
{
int c= sum(10,20);
}