Friday 13 January 2012

Simple Program in C

C programming language has conditions and loops also.Usually we are writing a program,and then  Preprocesser header files and then logics are given next step is closing functions and run a program.Some simple programs are compile with out loops and conditions.The hard programs that is using functions are don't run without using conditions and looping concepts also.So that is why we are using conditions as well as
loops.
        /*The simple program with out using any conditions and loops*/
            #include<stdio.h
         #include<conio.h>
         main()
         {
         int a,b,c;                                        //declaring variables
         clrscr();                                          //clearing the output screen
         printf("enter the value of a and b");  //formatted output statement
         scanf("%d%d",&a,&b);                      //formatted input statement
         c=a+b;                                           //a and b are added and stored in c
         printf("%d",c);                                //variable c is printed
         getch();
         }
In this program we are declaring variables a and b and c.And then get the values from the user and b.And the operator + will be used then two values are added and stored in variable c.<printf>and <scanf> functions are called formatted output and formatted input functions.Logical operator(+)is used in this program.The print the c value.The output will be displayed as follows:
enter the values and b 5,6
c=11




     






1 comment: