Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

ASSIGNMENT 3 FOR C LANGUAGE

Rating
-
Sold
-
Pages
11
Uploaded on
27-06-2025
Written in
2024/2025

ASSIGNMENT 3 IS BASED ON ARITHMETIC EXPRESSIONS AND PRECEDENCE ,LOOPS , STATEMENTS, PROGRAMS BASED ON WHILE ,DO WHILE AND FOR LOOP ,CONDITIONAL BRACHING PROGRAMS HELPS TO UNDERSTAND LANGUAGE EASILY AT A REASONABLE PRICE.

Institution
Course

Content preview

💡PROGRAMMING FOR PROBLEM SOLVING
IMPORTANT PRACTICE QUESTIONS (FOR,WHILE ,DO WHILE LOOP,IF ,IF ELSE,
CONDITIONAL BRANCHING PROGRAMS )




1. What is operator precedence in C?


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:
1.​ x = + 20​
1 + 20 = 21
2.​ 10 / (10 + 20)​
= 0.3

Without rules, different solutions are obtained. Therefore, precedence is defined; division has
precedence over addition, so case 1 is correct.



Operator Precedence and Associativity Table




NAME ASSOCIATIVITY PRECEDENCE

() function call, [] Array Left to Right 14
Subscript, . Dot, -> Arrow

, ++ Increment, -- Right to Left 13
Decrement

~ one's compliment, &
address operator

* Multiplication, % Modulus, Left to Right 12
/ Division

+ Addition, - Subtraction Right to Left



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.



(i) if statement



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;​
}​

,Example:




#include <stdio.h>​
int main()​
{​
int i = 10;​
if (i < 15)​
{​
printf("value is greater than 15");​
}​
}​




(ii) Nested if Statement



A nested if statement means an if statement inside another if statement.

Syntax:




if (condition 1)​
{​
if (condition 2)​
{​
statement 1;​
}​
}​

Example:

, #include <stdio.h>​
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");​
}​




(iii) if-else Statement



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:

Written for

Institution
Course

Document information

Uploaded on
June 27, 2025
Number of pages
11
Written in
2024/2025
Type
OTHER
Person
Unknown

Subjects

$7.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
muskanbhatoya

Get to know the seller

Seller avatar
muskanbhatoya CHANDIGARH GROUP OF COLLEGES
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
10 months
Number of followers
0
Documents
13
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions