Sunday, June 14, 2009
Tuesday, December 16, 2008
Meaning of 'C'..
C is a programming language.
(A set of instructions given to a computer in sequential order to perform some task is called a computer program. These instructions are given in a language that computer can understand & is called a programming language).
examples--> Basic, Pascal, COBOL, FORTRAN, Alogal, C, C++, Java, c# etc..
Some of them are task specific. It means they could perform only certain specific tasks.
while we required a language which had the capability to perform all tasks & could include modern programming. So keeping in mind all this, a new language named 'C' was developed.
C is the birth of Modern Programming.
It initially needs a header file n a function.
egs--> stdio.h, conio.h, math.h, stdlib.h etc etc..
At ground level we just need two header files - stdio.h and conio.h..Header files are those which contain functions like printf , scanf etc etc..
Lets make a program to print the word 'Hello'.
With this you'll be more clear..
#include
#include
main ()
{
clrscr ();
printf("Hello");
}
This is our program.
Here "#include" is the processor. With this only we can open the header files..
stdio.h contains printf while clrscr which means to clear the junk values of output screen is contained in conio.h header file.
{ } are known as braces. the functioning part has to be enclosed in the braces and the most important thing is that we have to put semi colon';' at the end of every funtion otherwise it'll show errors..
Now we'll make a progrm to print hello and welcome to c program-->
#include
#include
main ()
{
clrsc();
printf("hello\n");
printf("welcome to c program");
getch ();
}
Output will be--
hello
welcome to c program
>>"we write '\n' so that the rest is printed in next line"..
Now a program to add two numbers>>
#include
#include
main ()
{
int i,j,k;
clrscr ();
i=5;
j=21;
k=i+j;
printf("sum is %d",k);
getch ();
}
>> getch means get character. Its used to restore the screen..
In this program we gave 2 specific numbers.. Now we'll write a program in which any two random nos will be accepted and their sum will be given..
#include
#include
main ()
{
int i,j,k;
clrscr ();
printf("enter 1st number:");
scanf("%d",&i);
printf("enter 2nd no:");
scanf("%d",&j);
k=i+j;
printf("sum is %d",k);
getch ();
}
>> when we want the computer to accept a no., then we scan it..
SOME RELATED QUESTIONS....
1Q) To find the perimeter of a rectangle.
2Q) To find area of the rectangle.
3Q) Accept the price of an item and calculate its price after giving 10% discount.
4Q) Accept the salary of a person. Calculate net salary of a person after getting 2% HRA and 4% DA. (where net salary is salary + HRA + DA).
Now you can solve these. If any problem comes then contact me or ask me by mailing me..
(A set of instructions given to a computer in sequential order to perform some task is called a computer program. These instructions are given in a language that computer can understand & is called a programming language).
examples--> Basic, Pascal, COBOL, FORTRAN, Alogal, C, C++, Java, c# etc..
Some of them are task specific. It means they could perform only certain specific tasks.
while we required a language which had the capability to perform all tasks & could include modern programming. So keeping in mind all this, a new language named 'C' was developed.
C is the birth of Modern Programming.
It initially needs a header file n a function.
egs--> stdio.h, conio.h, math.h, stdlib.h etc etc..
At ground level we just need two header files - stdio.h and conio.h..Header files are those which contain functions like printf , scanf etc etc..
Lets make a program to print the word 'Hello'.
With this you'll be more clear..
#include
#include
main ()
{
clrscr ();
printf("Hello");
}
This is our program.
Here "#include" is the processor. With this only we can open the header files..
stdio.h contains printf while clrscr which means to clear the junk values of output screen is contained in conio.h header file.
{ } are known as braces. the functioning part has to be enclosed in the braces and the most important thing is that we have to put semi colon';' at the end of every funtion otherwise it'll show errors..
Now we'll make a progrm to print hello and welcome to c program-->
#include
#include
main ()
{
clrsc();
printf("hello\n");
printf("welcome to c program");
getch ();
}
Output will be--
hello
welcome to c program
>>"we write '\n' so that the rest is printed in next line"..
Now a program to add two numbers>>
#include
#include
main ()
{
int i,j,k;
clrscr ();
i=5;
j=21;
k=i+j;
printf("sum is %d",k);
getch ();
}
>> getch means get character. Its used to restore the screen..
In this program we gave 2 specific numbers.. Now we'll write a program in which any two random nos will be accepted and their sum will be given..
#include
#include
main ()
{
int i,j,k;
clrscr ();
printf("enter 1st number:");
scanf("%d",&i);
printf("enter 2nd no:");
scanf("%d",&j);
k=i+j;
printf("sum is %d",k);
getch ();
}
>> when we want the computer to accept a no., then we scan it..
SOME RELATED QUESTIONS....
1Q) To find the perimeter of a rectangle.
2Q) To find area of the rectangle.
3Q) Accept the price of an item and calculate its price after giving 10% discount.
4Q) Accept the salary of a person. Calculate net salary of a person after getting 2% HRA and 4% DA. (where net salary is salary + HRA + DA).
Now you can solve these. If any problem comes then contact me or ask me by mailing me..