basic programming and computer science topic description and discussion for students
bandicam 2017 01 23 20 38 45 832
Get link
Facebook
X
Pinterest
Email
Other Apps
This is just for your Knowledge.Those who want to start with java can find this Helpful.
Get link
Facebook
X
Pinterest
Email
Other Apps
Comments
Popular posts from this blog
Solutions:- 1) W.A.P. to display roots of a quadratic equation where coefficients a,b,c are given ? #include<iostream> #include<cmath> using namespace std; int main() { int a,b,c; float D,r1,r2; cout<<"Enter the Coefficients of the quadratic equation-"; cin>>a>>b>>c; D=pow(b,2) - (4*a*c); if(D<0) {cout<<"\nNo Real Roots"; return 0;} else {if(D>0) { cout<<"\nDistinct Real Roots\n"; r1=(-b + sqrt(D))/(2*a); r2=(-b - sqrt(D))/(2*a); cout<<"Roots ="<<r1<<" "<<r2;} else{ cout<<"\nEqual Roots\n";r1=-b/(2*a); cout<<"Root ="<<r1; }} return 0;} 2) W.A.P. to check whether a given number is prime or not ? #include<iostream> using namespace std; int main() { int n; char p='Y'; cout<<"Enter a number="; cin>>n; if(n==1) p='N'; for(int i=2;i<=n/2;...
Hello Everyone. Now Lets Talk about the very useful if-else statements. It is a very simple type of Selective Statement but is of great Use. A If statement is Generally used to Compare Standard Data Types like integer,char ,double,etc. which is put inside parenthesis, whose result is given in either true or false,or 0 or 1, and is then checked by the compiler, if it is true ,the statements following this if statement will execute ,Otherwise it will not execute if statement block and execute the else block if present. An else block is a Block that executes in case if statement is not satisfied. Now Coming to the example.It will be more clear when you see the Example. int n=5; if(n>2) { n++; n = 2*n; } else{ n--; n=2*n; } Here, We have Declared a integer type variable n with value 5. Then there is an if statement with test expression = n>2 . Since, n=5 ,i.e., n>2 , Therefore, this condition is true and satisfied. Therefore , if statement block will execu...
Comments
Post a Comment