SlideShare a Scribd company logo
1 of 1
Download to read offline
C Language Problem
Please Explain If int n1 = 5, and int d1 = 2, what are the results of the following operations?
(assume double frac) frac = (double)n1/(double)d1;frac = (double)n1/d1 + 3.5; frac =
(double)(n1/d1) + 2.5;
Solution
Here the heart of functionality is typecasting.
What is typecasting?
Type casting is a way to convert a variable from one data type to another data type.
frac = (double)n1/(double)d1;
n1 = 5 and d1 = 2
what this (double)n1/(double)d1 does..
here typecasting is preforming so
(double)n1 = 5.000000
(double)d1 = 2.000000
frac = 5.000000/2.000000
frac = 2.500000
frac = (double)n1/d1 + 3.5;
Here only n1 is typecasted into double
so n1 is 5.000000
and d1 is 2
(double)n1/d1 + 3.5 => (5.000000 / 2) + 3.5 => 2.500000 + 3.5 => 6.000000
frac is 6.000000
frac = (double)(n1/d1) + 3.5;
here there is no typecasting between n1 and d1 ... after division is perform then typecasting is
going to applied
so
(double)(n1/d1) + 3.5
(double)(5/2) + 3.5
(double)(2) + 3.5
2.000000 + 3.5
5.500000
Answer is 5.500000

More Related Content

More from alokkesh

LinearPerson.javaPlease help me the JAVA programPlease provide t.pdf
LinearPerson.javaPlease help me the JAVA programPlease provide t.pdfLinearPerson.javaPlease help me the JAVA programPlease provide t.pdf
LinearPerson.javaPlease help me the JAVA programPlease provide t.pdf
alokkesh
 
Flag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdf
Flag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdfFlag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdf
Flag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdf
alokkesh
 
For our discussion question, we focus on recent trends in security t.pdf
For our discussion question, we focus on recent trends in security t.pdfFor our discussion question, we focus on recent trends in security t.pdf
For our discussion question, we focus on recent trends in security t.pdf
alokkesh
 
Fill in the blanksMicronutrients this refers to a sub-category o.pdf
Fill in the blanksMicronutrients this refers to a sub-category o.pdfFill in the blanksMicronutrients this refers to a sub-category o.pdf
Fill in the blanksMicronutrients this refers to a sub-category o.pdf
alokkesh
 
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdfecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
alokkesh
 
DiARTHROIDAL joints can be classified based on their characteristics.pdf
DiARTHROIDAL joints can be classified based on their characteristics.pdfDiARTHROIDAL joints can be classified based on their characteristics.pdf
DiARTHROIDAL joints can be classified based on their characteristics.pdf
alokkesh
 
Cite the distinction between graphite and carbon. Carbon and graphit.pdf
Cite the distinction between graphite and carbon.  Carbon and graphit.pdfCite the distinction between graphite and carbon.  Carbon and graphit.pdf
Cite the distinction between graphite and carbon. Carbon and graphit.pdf
alokkesh
 

More from alokkesh (20)

most extra cellular environments contain a high concentration of sod.pdf
most extra cellular environments contain a high concentration of sod.pdfmost extra cellular environments contain a high concentration of sod.pdf
most extra cellular environments contain a high concentration of sod.pdf
 
Let X be the prive of a meal at a local diner( X = $8,$10,and $12) a.pdf
Let X be the prive of a meal at a local diner( X = $8,$10,and $12) a.pdfLet X be the prive of a meal at a local diner( X = $8,$10,and $12) a.pdf
Let X be the prive of a meal at a local diner( X = $8,$10,and $12) a.pdf
 
LinearPerson.javaPlease help me the JAVA programPlease provide t.pdf
LinearPerson.javaPlease help me the JAVA programPlease provide t.pdfLinearPerson.javaPlease help me the JAVA programPlease provide t.pdf
LinearPerson.javaPlease help me the JAVA programPlease provide t.pdf
 
is acute or chronic exposure to heptachlor more of a danger to human.pdf
is acute or chronic exposure to heptachlor more of a danger to human.pdfis acute or chronic exposure to heptachlor more of a danger to human.pdf
is acute or chronic exposure to heptachlor more of a danger to human.pdf
 
In “Intellectual Property and the Information Age,” Richard T. De Ge.pdf
In “Intellectual Property and the Information Age,” Richard T. De Ge.pdfIn “Intellectual Property and the Information Age,” Richard T. De Ge.pdf
In “Intellectual Property and the Information Age,” Richard T. De Ge.pdf
 
How does horizontal transfer affect the evolution of anti-biotic res.pdf
How does horizontal transfer affect the evolution of anti-biotic res.pdfHow does horizontal transfer affect the evolution of anti-biotic res.pdf
How does horizontal transfer affect the evolution of anti-biotic res.pdf
 
Flag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdf
Flag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdfFlag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdf
Flag this QuestionQuestion 12 1 ptsPolytene chromosomes arise fr.pdf
 
Genetic drift tends to genetic variation wITHIN small populations, an.pdf
Genetic drift tends to genetic variation wITHIN small populations, an.pdfGenetic drift tends to genetic variation wITHIN small populations, an.pdf
Genetic drift tends to genetic variation wITHIN small populations, an.pdf
 
For our discussion question, we focus on recent trends in security t.pdf
For our discussion question, we focus on recent trends in security t.pdfFor our discussion question, we focus on recent trends in security t.pdf
For our discussion question, we focus on recent trends in security t.pdf
 
Fill in the blanksMicronutrients this refers to a sub-category o.pdf
Fill in the blanksMicronutrients this refers to a sub-category o.pdfFill in the blanksMicronutrients this refers to a sub-category o.pdf
Fill in the blanksMicronutrients this refers to a sub-category o.pdf
 
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdfecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
ecourses.pvamu.edu Help English United States en us) Question4 Ma.pdf
 
Explain why several versions of nMOS transistor models and pMOS trans.pdf
Explain why several versions of nMOS transistor models and pMOS trans.pdfExplain why several versions of nMOS transistor models and pMOS trans.pdf
Explain why several versions of nMOS transistor models and pMOS trans.pdf
 
Explain How Culture influences the way mangers perform their four ma.pdf
Explain How Culture influences the way mangers perform their four ma.pdfExplain How Culture influences the way mangers perform their four ma.pdf
Explain How Culture influences the way mangers perform their four ma.pdf
 
Describeillustrate the construction used by the ancient Indians to s.pdf
Describeillustrate the construction used by the ancient Indians to s.pdfDescribeillustrate the construction used by the ancient Indians to s.pdf
Describeillustrate the construction used by the ancient Indians to s.pdf
 
Describe the factors that contribute to a membrane potential. What i.pdf
Describe the factors that contribute to a membrane potential. What i.pdfDescribe the factors that contribute to a membrane potential. What i.pdf
Describe the factors that contribute to a membrane potential. What i.pdf
 
DiARTHROIDAL joints can be classified based on their characteristics.pdf
DiARTHROIDAL joints can be classified based on their characteristics.pdfDiARTHROIDAL joints can be classified based on their characteristics.pdf
DiARTHROIDAL joints can be classified based on their characteristics.pdf
 
Define and explain chemical equilibrium Include the defenition o.pdf
Define and explain chemical equilibrium Include the defenition o.pdfDefine and explain chemical equilibrium Include the defenition o.pdf
Define and explain chemical equilibrium Include the defenition o.pdf
 
Cite the distinction between graphite and carbon. Carbon and graphit.pdf
Cite the distinction between graphite and carbon.  Carbon and graphit.pdfCite the distinction between graphite and carbon.  Carbon and graphit.pdf
Cite the distinction between graphite and carbon. Carbon and graphit.pdf
 
According to Cisco design theory for a fully switched network, hosts.pdf
According to Cisco design theory for a fully switched network, hosts.pdfAccording to Cisco design theory for a fully switched network, hosts.pdf
According to Cisco design theory for a fully switched network, hosts.pdf
 
A saturated sample has a mass 0.69 kilograms when wet and 0.5 kg whe.pdf
A saturated sample has a mass 0.69 kilograms when wet and 0.5 kg whe.pdfA saturated sample has a mass 0.69 kilograms when wet and 0.5 kg whe.pdf
A saturated sample has a mass 0.69 kilograms when wet and 0.5 kg whe.pdf
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 

C Language ProblemPlease Explain If int n1 = 5, and int d1 = 2, wh.pdf

  • 1. C Language Problem Please Explain If int n1 = 5, and int d1 = 2, what are the results of the following operations? (assume double frac) frac = (double)n1/(double)d1;frac = (double)n1/d1 + 3.5; frac = (double)(n1/d1) + 2.5; Solution Here the heart of functionality is typecasting. What is typecasting? Type casting is a way to convert a variable from one data type to another data type. frac = (double)n1/(double)d1; n1 = 5 and d1 = 2 what this (double)n1/(double)d1 does.. here typecasting is preforming so (double)n1 = 5.000000 (double)d1 = 2.000000 frac = 5.000000/2.000000 frac = 2.500000 frac = (double)n1/d1 + 3.5; Here only n1 is typecasted into double so n1 is 5.000000 and d1 is 2 (double)n1/d1 + 3.5 => (5.000000 / 2) + 3.5 => 2.500000 + 3.5 => 6.000000 frac is 6.000000 frac = (double)(n1/d1) + 3.5; here there is no typecasting between n1 and d1 ... after division is perform then typecasting is going to applied so (double)(n1/d1) + 3.5 (double)(5/2) + 3.5 (double)(2) + 3.5 2.000000 + 3.5 5.500000 Answer is 5.500000