SlideShare a Scribd company logo
1 of 13
Download to read offline
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

What's hot

Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solutionrohit kumar
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinShariful Haque Robin
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionrohit kumar
 
Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder Vishvesh Jasani
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C LanguageRAJWANT KAUR
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__elseeShikshak
 

What's hot (20)

Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
C Programming
C ProgrammingC Programming
C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Strings in c
Strings in cStrings in c
Strings in c
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
C functions
C functionsC functions
C functions
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Switch case in C++
Switch case in C++Switch case in C++
Switch case in C++
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
String functions in C
String functions in CString functions in C
String functions in C
 

Similar to Chapter 3 : Balagurusamy Programming ANSI in C

C Programming Interview Questions
C Programming Interview QuestionsC Programming Interview Questions
C Programming Interview QuestionsGradeup
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdSyed Mustafa
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CSyed Mustafa
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdfMaryJacob24
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3Vince Vo
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2Pamidimukkala Sivani
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptxramanathan2006
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2docSrikanth
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C ProgrammingQazi Shahzad Ali
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESUnit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESLeahRachael
 
programs of c www.eakanchha.com
 programs of c www.eakanchha.com programs of c www.eakanchha.com
programs of c www.eakanchha.comAkanchha Agrawal
 

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

Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
C Programming Interview Questions
C Programming Interview QuestionsC Programming Interview Questions
C Programming Interview Questions
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcd
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
C Programming
C ProgrammingC Programming
C Programming
 
Technical questions
Technical questionsTechnical questions
Technical questions
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
Ch03
Ch03Ch03
Ch03
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2doc
 
Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESUnit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
 
programs of c www.eakanchha.com
 programs of c www.eakanchha.com programs of c www.eakanchha.com
programs of c www.eakanchha.com
 

More from BUBT

Lab report cover page
Lab report cover page Lab report cover page
Lab report cover page BUBT
 
Project report title cover page
Project report title cover pageProject report title cover page
Project report title cover pageBUBT
 
Implementation Of GSM Based Fire Alarm and Protection System
Implementation Of GSM Based Fire Alarm and Protection SystemImplementation Of GSM Based Fire Alarm and Protection System
Implementation Of GSM Based Fire Alarm and Protection SystemBUBT
 
Student Attendance
Student AttendanceStudent Attendance
Student AttendanceBUBT
 
Reasoning for Artificial Intelligence Expert
Reasoning for Artificial Intelligence ExpertReasoning for Artificial Intelligence Expert
Reasoning for Artificial Intelligence ExpertBUBT
 
Auto Room Lighting and Door lock Report
Auto Room Lighting and Door lock ReportAuto Room Lighting and Door lock Report
Auto Room Lighting and Door lock ReportBUBT
 
Auto Room Lighting System
Auto Room Lighting SystemAuto Room Lighting System
Auto Room Lighting SystemBUBT
 
Doorlock
DoorlockDoorlock
DoorlockBUBT
 
Ultra Dense Netwok
Ultra Dense NetwokUltra Dense Netwok
Ultra Dense NetwokBUBT
 
Bangladesh University of Business and Technology
Bangladesh University of Business and Technology Bangladesh University of Business and Technology
Bangladesh University of Business and Technology BUBT
 
Art Gallery Management System
Art Gallery Management SystemArt Gallery Management System
Art Gallery Management SystemBUBT
 
Shop management system
Shop management systemShop management system
Shop management systemBUBT
 

More from BUBT (12)

Lab report cover page
Lab report cover page Lab report cover page
Lab report cover page
 
Project report title cover page
Project report title cover pageProject report title cover page
Project report title cover page
 
Implementation Of GSM Based Fire Alarm and Protection System
Implementation Of GSM Based Fire Alarm and Protection SystemImplementation Of GSM Based Fire Alarm and Protection System
Implementation Of GSM Based Fire Alarm and Protection System
 
Student Attendance
Student AttendanceStudent Attendance
Student Attendance
 
Reasoning for Artificial Intelligence Expert
Reasoning for Artificial Intelligence ExpertReasoning for Artificial Intelligence Expert
Reasoning for Artificial Intelligence Expert
 
Auto Room Lighting and Door lock Report
Auto Room Lighting and Door lock ReportAuto Room Lighting and Door lock Report
Auto Room Lighting and Door lock Report
 
Auto Room Lighting System
Auto Room Lighting SystemAuto Room Lighting System
Auto Room Lighting System
 
Doorlock
DoorlockDoorlock
Doorlock
 
Ultra Dense Netwok
Ultra Dense NetwokUltra Dense Netwok
Ultra Dense Netwok
 
Bangladesh University of Business and Technology
Bangladesh University of Business and Technology Bangladesh University of Business and Technology
Bangladesh University of Business and Technology
 
Art Gallery Management System
Art Gallery Management SystemArt Gallery Management System
Art Gallery Management System
 
Shop management system
Shop management systemShop management system
Shop management system
 

Recently uploaded

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

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);