Qbunit 5
Qbunit 5
Qbunit 5
13. What is the difference between while loop and do…while loop?
In the while loop the condition is first executed. If the condition is true then it executes the body
of the loop. When the condition is false it comes of the loop. In the do…while loop first the
statement is executed and then the condition is checked. The do…while loop will execute at least
one time even though the condition is false at the very first time.
15. How many bytes are occupied by the int, char, float, long int and double?
int - 2 Bytes
char - 1 Byte float - 4 Bytes long int - 4 Bytes double - 8 Bytes
22. What will happen when you access the array more than its dimension?
When you access the array more than its dimensions some garbage value is
stored in the array.
23. Write the limitations of getchar( ) and sacnf( ) functions for reading strings (JAN 2009)
getchar( )
To read a single character from stdin, then getchar() is the appropriate.
scanf( )
scanf( ) allows to read more than just a single character at a time.
31. What is the output of the following program when, the name given with spaces?
main()
{
char name[50]; printf(“\n name\n”); scanf(“%s, name); printf(“%s”,name);
}
Output:
Lachi (It only accepts the data upto the spaces)
33. Why we don’t use the symbol ‘&’ symbol, while reading a String through scanf()?
The ‘&’ is not used in scanf() while reading string, because the character variable
itself specifies as a base address.
Example: name, &name[0] both the declarations are same.
34. What is the difference between static and auto storage classes?
Static Auto
Storage Memory Memory
Initial value Zero Garbage value
Scope Local to the block in Local to the block in which
Life which the variables is the variable is defined.
defined The block in which the
Value of the variable variable is defined.
persists
between different
function calls.
37. List out some of the rules used for ‘C’ programming.
· All statements should be written in lower case letters. Upper case letters are only for
symbolic constants.
· Blank spaces may be inserted between the words. This improves the readability of statements.
· It is a free-form language; we can write statements anywhere between ‘{‘ and ‘}’. a = b + c;
d = b*c;
(or)
a = b+c; d = b*c;
· Opening and closing braces should be balanced.
50. Write a program to swap the values of two variables (without temporary variable).
#include <stdio.h>
#include <conio.h>
void main( )
{
int a =5; b = 10;
clrscr( );
prinf(“Before swapping a = %d b = %d “, a , b);
a = a + b; B = a – b;
a = a – b;
prinf(“After swapping a = %d b = %d”, a,b);
getch( );
}
Output:
Before swapping a = 5 b = 10
After swapping a = 10 b = 5
51. Write short notes about main ( ) function in ’C’ program. (MAY 2009)
· Every C program must have main ( ) function.
· All functions in C, has to end with ‘( )’ parenthesis.
· It is a starting point of all ‘C’ programs.
· The program execution starts from the opening brace ‘{‘ and ends with closing brace
‘}’, within which executable part of the program exists.