






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
THIS PDF IS PRACTICING IMP QUES FOR EXAMS FOR C .TOPICS INCLUDES OPERATORS PRECEDENCE, CONDITIONAL BRANCHING STATEMENTS, ARITHMETIC EXPRESSIONS. for,while and do while loops,PROGRAM FOR for LOOP.MY NOTES IS EASY TO UNDERSTAND AND IS REASONABLE WITH THE PRICE. CHECK IT OUT .
Typology: Study notes
1 / 11
This page cannot be seen from the preview
Don't miss anything!
Operator precedence in C dictates the order in which the operators will be evaluated in an expression. Associativity , on the other hand, defines the order in which the operators of the same precedence will be evaluated. Associativity can occur from either left to right or right to left.
Example:
Without rules, different solutions are obtained. Therefore, precedence is defined; division has precedence over addition, so case 1 is correct.
() function call, [] Array Subscript,. Dot, -> Arrow
Left to Right 14
++ Increment, -- Decrement
Right to Left 13
~ one's compliment, & address operator
Left to Right 12
2. Name three conditional branching statements along with their
syntax.
The conditional branching statements help to jump from one part of the program to another depending on whether the condition is satisfied or not.
The if statement is the most simple decision-making statement. It is used to decide if a certain condition is true, then a block of code or statement is executed; otherwise not.
Syntax:
if (condition) { statement 1 ; // ... statement x; }
int main() { int x = 65 , y = 35 , z = 2 ; if (x > y) { if (x > z) { printf("x is greater than y and z"); } } printf("End of program"); }
The if statement executes if a specified condition is true. If the condition is false, the else statement can be executed.
Syntax:
if (condition) { Statement 1 ; } else { Statement 2 ; }
Example:
int main() { int x = 10 ; if (x % 2 == 0 ) { printf("Even"); } else { printf("Odd"); } }
3. Explain Arithmetic expression with the help of suitable example.
An arithmetic expression consists of operators and operands. It is used to perform calculations to achieve a specific goal or task.
Example: C = A + B;
● Operands : Operands are the values or variables on which operations are being performed. In the above given expression, A and B are the operands. ● Operator : The symbols which are used to perform operations on operands are known as operators. In the above given example, the addition + sign is the arithmetic operator.
Full Example Code:
A for loop executes the statements of a program repeatedly several times until a given condition returns false. It is a pre-test loop.
Syntax:
for (initialization; condition; update) { statements; }
Example:
int main() { for (int i = 0 ; i <= 10 ; i++) { printf("%d\n", i); } return 0 ; }
Output:
It is a pre-test loop; it first tests a conditional expression. As long as the conditional expression is true, the loop body statement will be executed.
Syntax:
while (condition) { Statement; update (increase or decrease); }
Example:
int main() { int i = 0 ; while (i < 10 ) { printf("%d\n", i); i++; } return 0 ;
int main() { int a = 1 ; do { printf("%d\n", a); a++; } while (a < 10 ); return 0 ; }
Output:
5. Construct a table of 2 using for loop.
Example:
int main() { int i; for (i = 1 ; i <= 10 ; i++) { printf("2 x %d = %d\n", i, 2 * i); } return 0 ; }
Output:
2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 2 x 10 = 20