Professional Documents
Culture Documents
PST Unit 2
PST Unit 2
PST Unit 2
Formatted output [printf() ]: It is a statement used to print the values using field-width specification
and escape sequence so the output looks neat and presentable.
Syntax: printf(<format specifier>list of variables)
int a;
float b;
char c;
scanf(“%d %f %c”, &a,&b,&c);
printf(“%d %f %c”, a,b,c);
5. Explain the use of break and continue.
The break keyword is used to terminate any of the looping constructs. This keyword is always used in
the connection with ‘if’ within a looping construct.
Syntax: while(condition)
{
……………..
if(condition)
break;
………………..
………………..
}
When the continue is encountered, it transfers the control back to the loop condition by skipping the
rest of the statements of the body of the loop. The continue keyword only works with loops.
Syntax: while(condition)
{
……………..
if(condition)
continue;
………………..
………………..
}
6. Explain goto statements with examples.
It is an unconditional branching statement where the control of the program transfers from one part of
the program to another directly.
Syntax: go to<label name>
Ex: {
if(a%2==0)
go to even;
………………
………………..
………………..
even: printf(“\n Even number”);
go to stop;
}
7. How to initialize an array of pointer.
Array of pointer is also known as table of strings can be initialized as :
char *state_name[3]= { “Karnataka”,
“Tamil Nadu”,
“Kerala” };
8. Define pointer with an example.
A pointer is a variable which holds the address of another variable.
Int a;
Int *ptr_a;
ptr_a = &a;
9. Define array with example.
Array is a bounded collection of elements of same datatypes.
Ex: int Regno[5]= {10,20,30,40,50};
Regno[0] Regno[1] Regno[2] Regno[3] Regno[4]
10 20 30 40 50
10. What are command line argument?
When a parameter is supplied to a program during the execution then such as parameter is called
command line argument.
Syntax: main(int argc, char*argv[])
Ex: copy a file from FILE_A to FILE_B
(name of the program COPYPRG.c)
argc -3
argv[0]-> COPYPRG.c
argv[1]-> FILE_A
argv[2]-> FILE_B
Long Answers