c programming
Download
Skip this Video
Download Presentation
C Programming

Loading in 2 Seconds...

play fullscreen
1 / 9

C Programming - PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on

C Programming. printf. int printf ( const char * format, ... ); printf ("Characters: %c \n", \'a\'); printf ("Decimals: %d %f\n", 1977, 3.14);. Printf - float. %f – floating point. Displays upto 6 decimal places. %0.2f- displays 2 decimal places

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' C Programming' - fiona


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
printf
printf
  • intprintf ( const char * format, ... );
  • printf ("Characters: %c \n", \'a\');
  • printf ("Decimals: %d %f\n", 1977, 3.14);
printf float
Printf - float
  • %f – floating point. Displays upto 6 decimal places.
  • %0.2f- displays 2 decimal places
  • %5.1f- displays 4 digits including one after decimal point. If less digits are there then it gives spaces instead
  • %05.1f- displays 4 digits including one after decimal point. If less digits are there then it gives leading zeros.
printf decimal
Printf – decimal
  • %5d- displays a the value. If number of digits is less than 5 then leading spaces are given.
  • %-5d- here trailing spaces are given.
  • %05d- here instead of spaces zeros are given.
scanf
Scanf
  • Reads data from standard input and stores them according to the parameter format into the locations pointed by the additional arguments.
  • Eg: -inti;

scanf ("%d",&i);

coding standards
Coding standards
  • Variable
    • Each variable must strictly be named in a meaningful way
    • only one declaration of one variable in one line
    • Eg: -inttotal_marks;

inttotalmarks;

  • File Name
    • Filenames should be all lowercase and can include underscores (_) or dashes
    • Eg:- helloworld.c or hello_world.c
coding standards1
Coding standards
  • Comments
    • Meaningful comments and should be proper sentences
    • No spelling mistakes in comments
  • Indenting
    • Two spaces should be used.
  • Line length
    • Max 80 characters per line
question 1
Question 1
  • Swap two variables using a temporary variable.
  • Input
    • Enter integer value 1- 10
    • Enter integer value 2- 20
  • Output
    • Value 1= 10
    • Value 2= 20
    • After Swapping
    • Value 1= 20
    • Value 2= 10
question 2
Question 2
  • Compute volume of a cylinder
  • Input
    • Enter the radius of cylinder (float)
    • Enter height of cylinder in float
  • Output
    • Volume of the cylinder(round off to 2 decimal places) =
ad