C Two Marks
C Two Marks
C Two Marks
Variable:
A variable is a data name that is used to store a value. A variable may take different
values at different times. A variable can be chosen by the programmer in a meaningful way.
So as to reflect its function or nature in the program.
Eg:
city college a1
Total_mark Name Avg
Constant:
A constant is a value that does not change during the program execution. A constant used in
C does not occupy memory.
❖ The function scanf() is used for formatted input from the standard input and provides many
of the conversion facilities.
❖ It is used for formatted output to standard output device,( screen) . The format
specification contains string and the data to be output, as the arguments(parameter) to the
printf() function.
The operators that act upon a single operand to produce a new value is known as
unary operator.
Eg: minus operator(-) ,Increment operator (++)
The formal parameters are used to collect values or address from the calling function to a
function being called.
A function may call another function. When a function calls itself, it is referred to as
recursive call the process is known as recursion. C provides very good facilities for recursion.
Variables that used as a local variable inside any function. This is the default one.
Initial value of variable is garbage value without initialization.
8. What are bitwise operators?
The bitwise operator performs the operation on bits (i.e, bit by bit). Using the bitwise
operators we can set/ reset/ check any bit in the value of the variable.
A pointer is a variable that represent the location (rather than the value) of a data item,
such as a variable or an array element. It is a variable that holds a memory address. This
address is the location of another variable or an array element in memory.
Keywords have fixed meaning and these meaning cannot be changed. These keywords
can be used only for their intended purpose, they cannot be used as programmer-defined
identifiers.
The for loop is entry controlled loop the provides a more concise loop control structure.
The general format of the loop is
for(intilialization;test-condition;increment/decrement)
{
Body of the loop;
}
The function that are predefined and supplied along with the compiler are known as built in
functions. They are also known as library function.
❖ If you declare within a function, It retains the value between function call.
❖ If it is declare a for a function name. It will be visible from other files if the function
declaration is as static.
❖ Static are global variables. By default we can use the global variables from outside files if
it is static global.
Two dimensional array follows row major order storage representation. The elements are
stored in row by row in the subsequent memory locations.
The relational operators are used to compare arithmetic, logical and character expressions.
We often compare two similar quantities and depending on their relation, take some
decisions. Each of these operator compares their left hand side with their right hand side. The
whole expression involving the relational operator then evaluates to an integer. It evaluates to
zero if the condition is false, and one if it is true
Operator Meaning
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to
The conditional operator consists of two symbols the question mark (?) and the colon (:).
The conditional expression of the form
variable = exp1?exp2:exp3;
conditional expression
where exp1 is test expression, exp2 is expression or constant or variable, exp3 is expression
or constant or variable.
The C Character set consists of upper and lower case alphabets, digits, special character and
white spaces. The alphabet and digits are together called the alphanumeric characters.
∙ Alphabets:
A,B,C,D,E………………………X,Y,Z
a,b,c,d,e………………………..x,y,z
∙ Digits:
0,1,2,3,4,5,6,7,8,9
∙ Special Character
+ *& ^ % $ # @ ! ~ ` -- = > < .\ , : ;
Operator Meaning
&& AND
|| OR
! NOT
The scanf() function can be used to enter any combination of data, like single character,
string, integer and float values. The general format of the scanf() function is
where format specifier string contains certain required formatting information, and avg1,
avg2….avgn are arguments that represent the individual input data item.
Actual parameters are used for passing values or address from the calling function to a
function being called.
The if-else statement performs one of the two possible actions. The general format is
if(test expression)
{
true-statement block;
}
else
{
false-statement block;
}
next statement.
Identifier are names that are given to various program elements such as variables, functions
and arrays. Identifier consist of letters and digits, in any order, except that the first character
must be a letter. Both upper and lower case letters are permitted though common usage
favours the use of lower letters. The underscore is treated as a letter.
Some combination of characters have the special functions such as \n, \t and \b. They are
called as escape sequence.
It returns a character just entered from the standard input unit that is keyboard. The entered
character can be either assigned to a character variable or enclosed to the computer screen.
A character constant is a single character, enclosed within the pair of single quotation mark.
Example : ‘x’ , ‘5’
A pointer declaration consists of a base type, an *, and the variable name. The general
form for declaring a pointer variable is
data_type *var_name;
For example
int *p;
∙ short
∙ long
∙ signed
∙ unsigned
In C operator can be classified into various categories based on their utility and
action, a list operator types are given below
∙ Arithmetic operators
∙ Relational operators
∙ Logical operators
∙ Assignment operators
∙ Increment operators
∙ Conditional operators
∙ Bitwise operators
∙ Comma operators
∙ Other operators
while(test_condition)
{
Body of the loop;
}
A looping is a process to do a job repeatedly with possible different data at each time.
The statement executed each time constitute the loop body, and each pass is called iteration.
A condition must be present to terminate the loop.
The putchar( ) function display one character on the display monitor. The character to
be displayed is of type char. The syntax for putchar( ) function is as given below
putchar(variable);
∙ Library function
∙ User – Defined function
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.
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
Memory Memory
Zero Garbage value
Storage Local to the block in which the Local to the block in which the
Initial value variables is defined is defined.
Scope Value of the variable persists The block in which the
Life between different function calls. variable is defined.
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.
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.