Learn programming for free
Getting started with C language.
In this blog we will learn basic of c language like how to take input,how to print output etc.These are very basic things that every student should know before moving on.
I will explain all these thing with very basic example,which is easy to understand.
#include<stdio.h>
int main()
{
int a,b,sum=0;
printf("Enter first number");
scanf("%d",&a);
printf("Enter second number");
scanf("%d",&b);
sum=a+b;
printf("Sum of two number is %d",sum);
return 0;
}
Explanation:
This is a simple program which takes two number from user and print their sum as a result.
- #include<stdio.h>
2. int main()
This is a function don't worry we will learn it in depth here just remember it that it is simply a function.
3. printf();
This statement is used to print information on screen.Like in our case it is will print Enter first number.
4. scanf();
This statement is used to take input from user.In our case it will take input from user as an integer.
5. sum = a+b;
I don't think this statement needs any explanation.This is a simple arithmetic operation.It will store sum of a and b into sum variable.
6. Finally it will print sum of two number as a result.
0 Comment to "Getting started with C language."
Post a Comment
If you have any doubts then let me know.