click on this link......

LinkGrand.com

Saturday, 30 March 2013

C printf and scanf

printf() and scanf() functions
    These two functions are defined in the header file stdio.h and they are used for ouput and input.

printf()
    This function is used to display messages and values of variables on the screen.  All messages must be enclosed in double quotes "...".  A message and a variable must be separated by a comma. The syntax is:
    printf ( "message ... %d %f %c ", variablename...);

scanf()
    This function is used to read a value from the keyboard and store it in a variable.
e.g.
    scanf("%d", &a);
    - will wait for an integer/whole value from the keyboard  and store it in a variable a.
e.g.
    scanf("%f", &b);
    - will wait for a real value from the keyboard and store it in a variable b.
e.g.
    scanf("%c", &d);
    - will wait for a character value from the keyboard and store it in a variable d.

Write a program to
1) Calculate area of a circle 
    A = pi*r*r
2) Calculate area of a rectangle
3) Calculate square and cube of a number.
4) Calculate the circumference of a cirle
5) Calculate temp in celcius
    c= 5/9 * (f-32)

No comments:

Post a Comment