Sunday 19 February 2012

Simply Adding two numbers

Hii guyzz
This manoj bojja with his 4th post

In this post you will be learning how to add two numbers , substract  and multiple etc

In c language we go through three main types of variables those are :-
1.)Integers
2.)Float
3.)Characters

now what are these ,,, it is easy to understand with exampels

integers---->>>> 1,2,30,100 etc  memory required to store integer is 2 bytess represented as "int".

float-------->>>>1.1,2.12,3.00,4.899 etc memory required to store integer is 4 bytes "float".

 characters------->>>>> a,b,c,d,e,f etc; memory required to store integer is 1 byte"char".


we all know algebra
if a=3
and b=2
what is a+b
it is................................5

you know algebra then you know  some what coding


Program to add two numbers

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;  // we are declaring that a,b,c are integer variables which stores integer values
clrscr();//clear the output screen
a=1;
b=8;
c=a+b;
//now how to print this answer on the screen ,,,,,,,we can take help of printf function

print("the sum of a and b is = %d",c);
getch();
}

you can make through what is happening but in printf  there something i.e., %d   it tells printf that the variable given is an integer value(c is an integer)

for float we use %f and for character we use %c

so u can make wonderful programs ie which can carry arthematic  operations.

That's all for today i will back with some good stuff tomorrow please practice and experiment new things.







No comments:

Post a Comment