Monday, March 7, 2016

Uses of for loop

                                                        Uses of for loop 



#include
#include

int main()
{

int far;
for(far = 0 ; far <= 300; far +=20)
printf("%3d %6.1f\n" ,far ,(5.0/9.0) * (far - 32));
getch();

return 0;
}

Char Data Type

 the char is used to storing  simple character  

 Unsigned: It consist only positive value i.e 0 to 255.
Signed: It consist both negative and positive values but in different formats like
-1 to -128
  • 0 to +127
And this all explanation is about 8 bit number system
Char has 1 byte only 

int main()
{ 
  char a ;

etc 

Working of a floating point data type

Working of a floating point data type 


Look  and understand the program and output shown below  simple understand what will
happen there




#include
#include

 int main(){

float far = 10;
         
       printf("%1.0f\n", far );
  printf("%2.0f\n", far);
  printf("%3.0f\n", far);
  printf("%4.0f\n", far);
  printf("%5.0f\n\n", far);

   printf("%1.1f\n", far );
  printf("%1.2f\n", far);
  printf("%1.3f\n", far);
  printf("%1.4f\n", far);
  printf("%1.5f\n", far);
   
getch();
return 0;
}







Working Of while loop

 The while loop operates as follows , the condition is tested ,if the it is true .
That is the condition is true that means

for example
            10 == 10 . or 10<20 .="" etc="" p="">If it is true the statement in the while loop will be work or execute 


while(i < j )
{
  stament for exection

}



Example
 
   while(far <= upper )

     {  

       celsius = 5 * (far - 32)/9;

       printf("%d\t%d\n", far ,celsius);

       far += step;

  }


it will execute till until the condition will get false  .

that is the far not equal to upper 


NB : 

   The body of the while loop may be single or more line .
  If there is a single line there is no need to add a the curly {} bracket 

Eg : 
       while(i < j)
        i = 2 * i ;  // it will repeat until the condition fall 



K&R text Book page 8

Variable and Arithmetic Operation 


#include

#include



 int main(){



int far ,celsius;

int lower ,upper,step;

  

  lower = 0;

  upper = 300;

  step =20;

   

   far = lower;

   

     while(far <= upper )

     {  

       celsius = 5 * (far - 32)/9;

       printf("%d\t%d\n", far ,celsius);

       far += step;

  }

 

 getch();

 return 0;

}



Uses Of %d in c Programming

 Many Of them getting confusion in %d.  lokk the various output at diffrent %d .ie . %2D ,%3d, %4d etc











Introduction to c programming

 Introduction to c programming 


First Program 

  Hello World Program

We need to compiler and an IDE  I am using Dev C++ IDE very good and simple one 


 It is a free and Open Source IDE .And  small in size download it from Here Click Here

first Program 

To print out the following words hello World