Online Programming

CHAPTER 4

May 20, 2011

(1) %d :- It is use for integer value
(1) %f :- It is use for float value

printf() has two syntax :-

(i) printf(" Messege ") :- It is use two print any text
(ii) printf("%d / %f",variable); :- Two print values of variable



/* Program to explain use of float */
main()
{
float a;
clrscr();
a=5/2;
printf("a=%f",a);
getch();
}

OUTPUT
a=2.0

In this program if we divide any integer value with another integer value than answer will be in decimal but it will not correct like above example.
To solve this problem one number should be float.


/* Program to explain use of float */
main()
{
float a;
clrscr();
a=5.0/2;
printf("a=%f",a);
getch();
}


OUTPUT
a=2.5


/* Program to find area of circle*/
main()
{
float a,r;
clrscr();
printf("Enter radius of circle ");
scanf("%f",&r);
a=3.141 * r * r;
printf("Area is %f",a);
getch();
}

OUTPUT
Enter radius of circle 2
Area is 8.564


QUESTION


Write a program to input principle,rate,time and calculate simple interest ?

 

CHAPTER 3

May 20, 2011
CHARACTER SET
The character set that can be used to form words, numbers and expressions are called character set.
Elements of character set :-
1.Letters --> A to Z , a to z
2.Digits --> 0 to 9
3. Special Characters --> +,-,*,/,:,;,(,),[,],{,},<,>,=,&,%,_,^,,,",',.,\,etc.
4.White spaces --> Newline,horizontal tab,carriage return,blank space.

IDENTIFIER

Identifier reverse to the name of variables,constants,functions and arrays.These are the user defined names end consi...

Continue reading...
 

CHAPTER 2

May 20, 2011

START PROGRAMMING
How to open C compiler:
1.Copy the C compiler file to the C drive.
2.Click START menu and select run option.
3.In run box type cmd command and click OK button.
4.Command prompt window will be open.
5.Type the following commands:
C:\Documents and settings\xp>cd\
C:\>cd turboc2
C:\turboc2>tc
FIRST PROGRAM :
Example 1

/*My first program*/
main()
{
clrscr(); /* This function clear screen */
printf("Good Afternoon");
/* This function prints message */

getch();
}...


Continue reading...
 

CHAPTER 1

May 20, 2011

INTRODUCTION OF 'C' LANGUAGE

Program : A program is a set of instructions.A C program is required to be compiled and linked before execution

Source code (.c) -----
Compilation--> Object code (.obj)

C is what is called a compiled language. This means that once you write your C program,
you must run at through a C compiler to turn your program into an executable that the ...


Continue reading...
 

Blog Archive