In this program we make use of the logic that an even number is always divisible by 2.Which means on diving a number by 2 the remainder must be zero.
Wednesday, 25 March 2015
C program to find roots of a quadratic equation
This program will print the roots for a given quadratic equation
Addition of two numbers in C++
For adding two numbers in c++,we have to declare variables.
We can accept numbers from user also using "cin" function or we can do it by declaring numbers to variables.
we will see both the methods.
#include<conio.h>
#include<iostream.h>
void main()
{
int x=2,y=2,z;
/*here variables are of integer type which stores two bytes ,you can take it as float (decimal values) */
z=x+y;
cout<<"\nX:"<<x<<"\nY:"<<y<<"Answer: "<<z;
/*accepting from user*/
cout<<"Enter two numbers: ";
cin>>x>>y;
z=x+y;
cout<<"\nX:"<<x<<"\nY:"<<y<<"Answer: "<<z;
getch();
}
#include<iostream.h>
void main()
{
int x=2,y=2,z;
/*here variables are of integer type which stores two bytes ,you can take it as float (decimal values) */
z=x+y;
cout<<"\nX:"<<x<<"\nY:"<<y<<"Answer: "<<z;
/*accepting from user*/
cout<<"Enter two numbers: ";
cin>>x>>y;
z=x+y;
cout<<"\nX:"<<x<<"\nY:"<<y<<"Answer: "<<z;
getch();
}
Output:

Addition of two numbers in C
For adding two numbers in c,we have to declare variables.
We can accept numbers from user also using scanf function or we can do it by declaring numbers to variables.
we will see both the methods.
Coding:
#include<conio.h>
#include<stdion.h>
void main()
{
int x=2,y=2,z;
/*here variables are of integer type which stores two bytes ,you can take it as float (decimal values) */
z=x+y;
printf("X: %d\n Y: %d \n Answer: %d",x,y,z);
/*accepting from user*/
printf ("Enter two numbers :");
scanf("%d%d",&x,&y);
z=x+y;
printf("X: %d\n Y: %d \n Answer: %d",x,y,z);
getch();
}
Output:
First program in C++
After installing the software of C language,we will start with our first program which will show how to print a string on Display Screen or Console.
Monday, 23 March 2015
First Program in Java
After installing the software of Java language,we will start with our first program which will show how to print a string on Display Screen or Console.
Sunday, 22 March 2015
How to set path in java
For setting the path For java,you need to download Java jdk.
You can Download it from below link.
Download From here: Click Here
After that,install it and follow the following steps to set the path:
- Goto MyComputer Properties.
- Click on Advance Tab.
|
|
|
|
|
|
|
Now You can goto CMD and you can compile and run your java programs. |
Subscribe to:
Posts (Atom)
