SlideShare a Scribd company logo
3
Most read
9
Most read
11
Most read
CHAPTER-3
Operators & Expressions
Review Questions:
3.1: True or False.
(a) All arithmetic operators have the same level of precedence. Ans. False
(b) The modulus operators can be used only with integers. Ans. True
(c) The operators <=, >= and != all enjoy the same level of priority. Ans. False
(d) During modulo division, the sign of the result is positive, if both the operands
are
of the same sign. Ans. True
(e) In C , if the data item is zero , it is considered false. Ans. True
(f) The expression!(x<=y) is same as the expression x>y. Ans. True
(g) A unary expression consists of only one operand with no operators. Ans.
False
(h) Associativity is used to decide which of several different expression is
evaluated first. Ans. False
(i) An expression statement is terminated with a period. Ans. False
(j) During the evaluation of mixed expressions, an implicit cast is generated
automatically. Ans. True
(k) An explicit cast can be used to change the expression. Ans. True
(l) Parentheses can be used to change the order of evaluation expressions. Ans.
True
3.2: Fill in the blank.
(a) The expression containing all the integer operands is called (arithmetic)
expression.
(b) The operator (%) cannot be used with the real operands.
(c) C supports as many as (6) relational operators.
(d) An expression that combines two or more relational expressions is termed as
(logical) expressions.
(e) The (sizeof ) operator returns the number of bytes the operand occupied.
(f) The order of evaluation can be used changed by using (parentheses) in an
expression.
(g) The use of (implicit type) on a variable can change its types in the memory.
(h) (Precedence) is used to determine the order in which different operators in an
expressions are evaluated.
3.3: Given the statement
Int a=10,b=20,c;
Determine true or false.
(a)The statement a=+10, is valid. Ans. True
(b) The expression a + 4/6 * 6/2 evaluates to 11. Ans. False
(c) The expression b + 3/2 * 2/3 evaluates to20. Ans. True
(d) The statement a+=b gives the values 30 to a and 20 to b. Ans. True
(e) The statement ++a++; gives the value 12 to a. Ans. False
(f)The statement a=1/b; assigns the value 0.5 to a. Ans. False
3.4:Declared a as int and b as float , state whether the following statement are true
or false.
(a)The statement a=1/3+1/3+1/3;assigns the value 1 to a. Ans .False
(b)The statement b=1.0/3.0+1.0/3.0+1.0/3.0;assgns a value 1.0 to b. Ans. True
(c)The statement b=1.0/3.0*3.0; gives a value 1.0 to b.Ans. True
(d)The statement b=1.0/3.0+2.0/3.0;assigns a value 1.0 to b.Ans. True
(e) The statement a=15/10.0+3/2; assigns a value 3 to a. Ans. False
3.5 Which of the following expression are true?
(a) !(5+5)>=10)Ans. False
(b) 5+5==10||1+3==5 Ans. True
(c) 5>10||10<20&&3<5 Ans. True
(d) 10!=15&&!(10<20)||15>30 Ans. False
3.6 Which of the following arithmetic expression is valid? If valid, give the value
of the expression; otherwise give reason.
(a) 25/3%2 Ans. Invalid
(b) +9/4+5 Ans. Valid
(c) 7.5%3 Ans. Invalid
(d) 14%3+7%2 Ans. Valid
(e)-14%3 Ans. Valid
(f) 15.25+-5.0 Ans. Valid
(g) (5/3)*3+5%3 Ans. Valid
(h) 21%(int)4.5 Ans. Valid
3.7:Write C assignment statement to evaluate the following equation:
(a)
Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int r,h;
float area;
clrscr();
printf("Enter the value of r,hn");
scanf(“%d %d",&r,&h);
area=(3.1416*r*r+2*3.1416*r*h);
printf("%f",area);
getch();
}
(d)
Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int m,h,v;
float Energy;
clrscr();
acceleration=9.8;
printf("Enter the value of m,h,vn");
scanf("%d%d%d",&m,&h,&v);
x=(9.8*h);
y=(v*v)/2;
Energy=m*(x+y);
printf("%f",Energy);
getch();}
(b)
Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int m1,m2,x,y;
float T;
clrscr();
printf("Enter the value of m1,m2n");
scanf("%f %f",&m1,&m2);
x=(2*m1*m2*9.8);
y=(m1+m2);
T=x/y;
printf("%f",T);
getch();
}
(c)
Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define cosx
void main()
{
int a,b,p,q,r,n,x;
float side;
clrscr();
printf("Enter the value of a,b,xn");
scanf("%d%d%d",&a,&b,&x);
p=(a*a+b*b);
r=(2*a*b);
n=cos(x);
side=sqrt(p-r*n);
printf("%f",side);
getch();
}
3.8:Indentyfy unnecessary parantheses in the following artimatic expression.
(a)(x-(y/5)+z)%8+25
(b)(x-y)*p+q
(c)(m*n)+(-x/y)
(d)x/3*y
3.9: Find the errors, if any, in the following assignment statement and rectify them.
(a)x=y=z=0.5,2.0, -5.75;
(b)m=++a*5;
(c)y=sqrt(100);
(d)p*=x/y;
(e)s/=5;
(f)a=b++-c*2;
3.10: Determine the value of each of the following logical expressions if a=5,b=10
and c=-6.
(a) a>b && a<c Value:0
(b) a<b && a>c Value:1
(c) a==c || b>a Value:1
(d) b>15 && c<0 || a>o Value:1
3.11:What is the out put of the following program?
Solution:
#include<stdio.h>
#include<conio.h>
void main();
{
/*...characters......*/
char x;
int y;
x=100;
y=125;
printf("%cn",x);
printf("%cn",y);
printf("%dn",x);
getch();
}
Output: 100
3.12:Find the output of the following program?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
/*....increment......*/
int x=100;
clrscr();
printf("%dn",10+x++);
printf("%dn",10+ ++x);
getch();}
Output:
110
112
3.13:What is printed by the following program?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int x=5,y=10,z=10;
clrscr();
x=y==z;
printf("%d",x);
getch();
}
Output: 1
314:What is the output of the following program ?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int x=100,y=200;
clrscr();
printf("%d",(x>y)?x:y);
}
Output: 200
3.15:What is the output of the following program?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned x=1;
signed char y=-1;
clrscr();
if(x>y)
printf("x>y");
else
printf("x<=y");
getch();
}
Output:
No
3.16:What is the output of the following program? Explain the output.
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int x=10;
clrscr();
if(x=20)
printf("TRUE");
else
printf("FALSE");
getch();
}
Output: TRUE
3.17: What is the error in each of the following statement?
(a) if(m==1 & n!=0)
printf("OK");
Output:
Error: Correct 'and' sign is '&&'
(b) if(x=<5)
printf("Jump");
Output:
Error: =<
Correct: <=
3.18:What is the error, if any ,in the following segment?
int x=10;
float y=4.25;
x= y%x;
Error: Illegal use of floating point.
3.19:What is printed when the following is execute?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int m;
clrscr();
for(m=0;m<3;++m)
printf("%dn",(m%2)?m:m+2);
getch();
}
Output:
2
1
4
3.20:What is the output of the following statement?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int m=-14,n=3;
clrscr();
printf("%dn",m/n*10);
n=-n;
printf("%d",m/n*10);
getch();
}
Output:
-40
40
Reference:
http://hstuadmission.blogspot.com/2010/12/solution-programming-in-ansi-c-
chapter.html

More Related Content

PDF
Chapter 2 : Balagurusamy_ Programming ANsI in C
PDF
Chapter 6 Balagurusamy Programming ANSI in c
PPT
Variables in C Programming
PPTX
Weighted and Non Weighted Codes
ODP
The Full Stack Web Development
ODP
Electronics and communication
PPT
Sliding window protocol
PPTX
Zener and avalanche diode
Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 6 Balagurusamy Programming ANSI in c
Variables in C Programming
Weighted and Non Weighted Codes
The Full Stack Web Development
Electronics and communication
Sliding window protocol
Zener and avalanche diode

What's hot (20)

PDF
Chapter 4 : Balagurusamy Programming ANSI in C
RTF
PDF
Chapter 1 : Balagurusamy_ Programming ANsI in C
PPT
RECURSION IN C
PPT
File handling in c
PPTX
Type casting in c programming
PPTX
Programming in C Presentation upto FILE
PPTX
Strings in C
PPTX
Conditional Statement in C Language
PPT
Programming in c
PPT
Branching in C
PPT
Basics of C programming
PPT
Types of operators in C
PPTX
Dynamic memory allocation in c
DOC
Difference between structure and union
PPTX
Call by value
PDF
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
PPT
Array in c
PPTX
Programming in c Arrays
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C
RECURSION IN C
File handling in c
Type casting in c programming
Programming in C Presentation upto FILE
Strings in C
Conditional Statement in C Language
Programming in c
Branching in C
Basics of C programming
Types of operators in C
Dynamic memory allocation in c
Difference between structure and union
Call by value
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
Array in c
Programming in c Arrays
Ad

Similar to Chapter 3 : Balagurusamy Programming ANSI in C (20)

PDF
Revision1 C programming
PDF
Revision1schema C programming
PDF
C Programming Interview Questions
PDF
VTU PCD Model Question Paper - Programming in C
PDF
answer-model-qp-15-pcd13pcd
DOCX
C interview question answer 2
PDF
C Operators and Control Structures.pdf
DOCX
C Programming
PPTX
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
DOCX
Technical questions
PPT
Java căn bản - Chapter3
DOCX
(Www.entrance exam.net)-tcs placement sample paper 2
PPTX
C Operators and Control Structures.pptx
DOC
C aptitude.2doc
DOC
Captitude 2doc-100627004318-phpapp01
PPTX
Operators inc c language
PPTX
Operators and expressions in c language
PPTX
Operators in C Programming
PDF
C programming Assignments and Questions.pdf
Revision1 C programming
Revision1schema C programming
C Programming Interview Questions
VTU PCD Model Question Paper - Programming in C
answer-model-qp-15-pcd13pcd
C interview question answer 2
C Operators and Control Structures.pdf
C Programming
M2 (1).pptxisedepofengiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Technical questions
Java căn bản - Chapter3
(Www.entrance exam.net)-tcs placement sample paper 2
C Operators and Control Structures.pptx
C aptitude.2doc
Captitude 2doc-100627004318-phpapp01
Operators inc c language
Operators and expressions in c language
Operators in C Programming
C programming Assignments and Questions.pdf
Ad

More from BUBT (13)

DOCX
Lab report cover page
DOCX
Project report title cover page
PPTX
Implementation Of GSM Based Fire Alarm and Protection System
PDF
Chapter 5 exercises Balagurusamy Programming ANSI in c
PPTX
Student Attendance
PPTX
Reasoning for Artificial Intelligence Expert
DOCX
Auto Room Lighting and Door lock Report
PPTX
Auto Room Lighting System
PPTX
Doorlock
PPTX
Ultra Dense Netwok
PPTX
Bangladesh University of Business and Technology
PPTX
Art Gallery Management System
PPTX
Shop management system
Lab report cover page
Project report title cover page
Implementation Of GSM Based Fire Alarm and Protection System
Chapter 5 exercises Balagurusamy Programming ANSI in c
Student Attendance
Reasoning for Artificial Intelligence Expert
Auto Room Lighting and Door lock Report
Auto Room Lighting System
Doorlock
Ultra Dense Netwok
Bangladesh University of Business and Technology
Art Gallery Management System
Shop management system

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Institutional Correction lecture only . . .
PPTX
Pharma ospi slides which help in ospi learning
PDF
Insiders guide to clinical Medicine.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Business Ethics Teaching Materials for college
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Classroom Observation Tools for Teachers
PDF
Pre independence Education in Inndia.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Module 4: Burden of Disease Tutorial Slides S2 2025
Institutional Correction lecture only . . .
Pharma ospi slides which help in ospi learning
Insiders guide to clinical Medicine.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
01-Introduction-to-Information-Management.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Basic Mud Logging Guide for educational purpose
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Business Ethics Teaching Materials for college
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
VCE English Exam - Section C Student Revision Booklet
Classroom Observation Tools for Teachers
Pre independence Education in Inndia.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...

Chapter 3 : Balagurusamy Programming ANSI in C

  • 1. CHAPTER-3 Operators & Expressions Review Questions: 3.1: True or False. (a) All arithmetic operators have the same level of precedence. Ans. False (b) The modulus operators can be used only with integers. Ans. True (c) The operators <=, >= and != all enjoy the same level of priority. Ans. False (d) During modulo division, the sign of the result is positive, if both the operands are of the same sign. Ans. True (e) In C , if the data item is zero , it is considered false. Ans. True (f) The expression!(x<=y) is same as the expression x>y. Ans. True (g) A unary expression consists of only one operand with no operators. Ans. False (h) Associativity is used to decide which of several different expression is evaluated first. Ans. False (i) An expression statement is terminated with a period. Ans. False
  • 2. (j) During the evaluation of mixed expressions, an implicit cast is generated automatically. Ans. True (k) An explicit cast can be used to change the expression. Ans. True (l) Parentheses can be used to change the order of evaluation expressions. Ans. True 3.2: Fill in the blank. (a) The expression containing all the integer operands is called (arithmetic) expression. (b) The operator (%) cannot be used with the real operands. (c) C supports as many as (6) relational operators. (d) An expression that combines two or more relational expressions is termed as (logical) expressions. (e) The (sizeof ) operator returns the number of bytes the operand occupied. (f) The order of evaluation can be used changed by using (parentheses) in an expression. (g) The use of (implicit type) on a variable can change its types in the memory. (h) (Precedence) is used to determine the order in which different operators in an expressions are evaluated. 3.3: Given the statement Int a=10,b=20,c; Determine true or false. (a)The statement a=+10, is valid. Ans. True (b) The expression a + 4/6 * 6/2 evaluates to 11. Ans. False (c) The expression b + 3/2 * 2/3 evaluates to20. Ans. True (d) The statement a+=b gives the values 30 to a and 20 to b. Ans. True
  • 3. (e) The statement ++a++; gives the value 12 to a. Ans. False (f)The statement a=1/b; assigns the value 0.5 to a. Ans. False 3.4:Declared a as int and b as float , state whether the following statement are true or false. (a)The statement a=1/3+1/3+1/3;assigns the value 1 to a. Ans .False (b)The statement b=1.0/3.0+1.0/3.0+1.0/3.0;assgns a value 1.0 to b. Ans. True (c)The statement b=1.0/3.0*3.0; gives a value 1.0 to b.Ans. True (d)The statement b=1.0/3.0+2.0/3.0;assigns a value 1.0 to b.Ans. True (e) The statement a=15/10.0+3/2; assigns a value 3 to a. Ans. False 3.5 Which of the following expression are true? (a) !(5+5)>=10)Ans. False (b) 5+5==10||1+3==5 Ans. True (c) 5>10||10<20&&3<5 Ans. True (d) 10!=15&&!(10<20)||15>30 Ans. False 3.6 Which of the following arithmetic expression is valid? If valid, give the value of the expression; otherwise give reason. (a) 25/3%2 Ans. Invalid (b) +9/4+5 Ans. Valid (c) 7.5%3 Ans. Invalid (d) 14%3+7%2 Ans. Valid (e)-14%3 Ans. Valid (f) 15.25+-5.0 Ans. Valid (g) (5/3)*3+5%3 Ans. Valid
  • 4. (h) 21%(int)4.5 Ans. Valid 3.7:Write C assignment statement to evaluate the following equation: (a) Solution: #include<stdio.h> #include<conio.h> #include<math.h> void main() { int r,h; float area; clrscr(); printf("Enter the value of r,hn"); scanf(“%d %d",&r,&h); area=(3.1416*r*r+2*3.1416*r*h); printf("%f",area); getch(); } (d) Solution: #include<stdio.h> #include<conio.h> #include<math.h> void main()
  • 5. { int m,h,v; float Energy; clrscr(); acceleration=9.8; printf("Enter the value of m,h,vn"); scanf("%d%d%d",&m,&h,&v); x=(9.8*h); y=(v*v)/2; Energy=m*(x+y); printf("%f",Energy); getch();} (b) Solution: #include<stdio.h> #include<conio.h> #include<math.h> void main() { int m1,m2,x,y; float T; clrscr(); printf("Enter the value of m1,m2n");
  • 6. scanf("%f %f",&m1,&m2); x=(2*m1*m2*9.8); y=(m1+m2); T=x/y; printf("%f",T); getch(); } (c) Solution: #include<stdio.h> #include<conio.h> #include<math.h> #define cosx void main() { int a,b,p,q,r,n,x; float side; clrscr(); printf("Enter the value of a,b,xn"); scanf("%d%d%d",&a,&b,&x); p=(a*a+b*b); r=(2*a*b); n=cos(x); side=sqrt(p-r*n); printf("%f",side);
  • 7. getch(); } 3.8:Indentyfy unnecessary parantheses in the following artimatic expression. (a)(x-(y/5)+z)%8+25 (b)(x-y)*p+q (c)(m*n)+(-x/y) (d)x/3*y 3.9: Find the errors, if any, in the following assignment statement and rectify them. (a)x=y=z=0.5,2.0, -5.75; (b)m=++a*5; (c)y=sqrt(100); (d)p*=x/y; (e)s/=5; (f)a=b++-c*2; 3.10: Determine the value of each of the following logical expressions if a=5,b=10 and c=-6. (a) a>b && a<c Value:0 (b) a<b && a>c Value:1 (c) a==c || b>a Value:1 (d) b>15 && c<0 || a>o Value:1 3.11:What is the out put of the following program? Solution: #include<stdio.h> #include<conio.h>
  • 8. void main(); { /*...characters......*/ char x; int y; x=100; y=125; printf("%cn",x); printf("%cn",y); printf("%dn",x); getch(); } Output: 100 3.12:Find the output of the following program? Solution: #include<stdio.h> #include<conio.h> void main() { /*....increment......*/ int x=100; clrscr(); printf("%dn",10+x++); printf("%dn",10+ ++x); getch();}
  • 9. Output: 110 112 3.13:What is printed by the following program? Solution: #include<stdio.h> #include<conio.h> void main() { int x=5,y=10,z=10; clrscr(); x=y==z; printf("%d",x); getch(); } Output: 1 314:What is the output of the following program ? Solution: #include<stdio.h> #include<conio.h> void main() { int x=100,y=200; clrscr(); printf("%d",(x>y)?x:y);
  • 10. } Output: 200 3.15:What is the output of the following program? Solution: #include<stdio.h> #include<conio.h> void main() { unsigned x=1; signed char y=-1; clrscr(); if(x>y) printf("x>y"); else printf("x<=y"); getch(); } Output: No 3.16:What is the output of the following program? Explain the output. Solution: #include<stdio.h> #include<conio.h> void main() {
  • 11. int x=10; clrscr(); if(x=20) printf("TRUE"); else printf("FALSE"); getch(); } Output: TRUE 3.17: What is the error in each of the following statement? (a) if(m==1 & n!=0) printf("OK"); Output: Error: Correct 'and' sign is '&&' (b) if(x=<5) printf("Jump"); Output: Error: =< Correct: <= 3.18:What is the error, if any ,in the following segment? int x=10; float y=4.25; x= y%x; Error: Illegal use of floating point.
  • 12. 3.19:What is printed when the following is execute? Solution: #include<stdio.h> #include<conio.h> void main() { int m; clrscr(); for(m=0;m<3;++m) printf("%dn",(m%2)?m:m+2); getch(); } Output: 2 1 4 3.20:What is the output of the following statement? Solution: #include<stdio.h> #include<conio.h> void main() { int m=-14,n=3; clrscr(); printf("%dn",m/n*10);