starting with a question

WAP to print simple interest if p = rs 1000, t =1 year, r = 10%

What happen if p dosen't equalizes rs1000

We require a special command (instructions) for asking a user a input!

scanf("%d",&a);

This is a function which reads input from user.

Syntax:

 

scanf("type specifiers", address of variable);

 

scanf("%d",&a);

Type Specifiers

This symbolizes about the type of variable.

eg: 

'%d' for int

'%c' for char

'%f' for float

'%s' for strings

ADDRESS OF &

&a;

 

will give actual address of the variable.

Playing with scanf()

WAP to find the area and circumference of Circle

AREA = pi*r*r

CIRCUMFERENCE=2*pi*r

For all who just forget! 

Output must be like this

//if r =1

Area = 3.14

Circumference = 6.28

Here the concept lies of \Escape Sequences\

REMEMBER REMEMBER ITS \ backslash \ 

ESCAPE SEQUENCES

  1. Have a special meaning
  2. represent symbol like new line(\n) and tab(\t)

write a statement to print double quotes(") over the output screen

printf("\"");

Homework

  1. WAP to output a table of any input.

  2.  

Copy of deck

By Pulkit Goyal

Copy of deck

  • 723