Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
22 views
Lecture 8 Coding Questions
Uploaded by
syash9457
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Lecture 8 Coding Questions For Later
Download
Save
Save Lecture 8 Coding Questions For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
22 views
Lecture 8 Coding Questions
Uploaded by
syash9457
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Lecture 8 Coding Questions For Later
Carousel Previous
Carousel Next
Save
Save Lecture 8 Coding Questions For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 22
Search
Fullscreen
‘Question Not ‘single File Programming Question Problem statement sarah is studying number theory ands curious about the sum of avisos of a given number. She wants to write a C++ program to calculate this. Can you help horn witing a program thot takes « positive integer as input an calculates the sum of ts dvsors using @ roference valable? Function Name: void calculateDivisersum Note: This is e'2ample question asked in infosys rerultmant. Input format: The input consists of an integer N Output format : Te output displaye the eum ofall the aivisars of N‘Output format : The output displays the sum of all the divisors of N. Code constraints : 1<= N= 00 ‘Sample test cases: Input: 5 Whitelist set: ‘Outputtices iret emsCnee sy Pesan e eeaa F void calculatepivisorsum(int num, int &sum) { re a irae ee ean ees eg Pec rene ener : 3 raccoons int N; Cea Bae PRE ete Tete neta eect) Coe Se RE el MSU otStotue Conect rt bined ft) Hes wes O Trescompled 2 Tnansubrited 1 Lowe Kany Gusten ype Shglaflamogrmming Subject C44 opie Rietone Sub Tope Relweneavaranae Suan teensy crate TD shom eetcase sree (7) Show eoiion est s/s Testooses Passed ‘compiier Messogetna at cepteseutnt Timotve) Time comploty space Compatty wossageSolution 1 Parra es ers using namespace std; void calculateDivisorsum(int number, int& sum) ( Sec Gi are recon eee eg if (number % i == 0) { Ere ey } i Cran Tv ules at rear ae Peyton tetra strc cout << divisorsum; SSeS‘ouesionno:2 Single Fle Programming Question sores oma ents ah eso analysts rumba dole tha sum she recent rte rogram ofa hase humus sia funeton eal wm) Teather ‘nroton sve created a progam fa slowshertoiput aca numbers ond amputathari uangine cones eal by Voie hn Sarohuns progre, snes prema art the rumba on by ne tr inpting enue. he progr noes the sunt. tune, th rumba ore oss vive, mecring ht he rg! elves oe nat modded. hs uncon ees og ta povided umber, occuulng em ‘ce me computations cares th rgto dps he sumo th een owing oth toque anaye the et rurale The Cal by Vue approach ensures a the ‘gra rursarsreman unsnanged, proving Saran th acuta rents and gresrng neg thei Sot ‘ote: nis sample question asad in Capgernnieetutner rot tormet ‘eatin helmut cana tne tn‘Output format: The output prints the sum of elements. ‘Sample test cases: Input: Output: 5 220 “u 36 Input2: output2: e 2046 Pry 456 709 uz 258 369 951 753Whitelist gd cect eH ae Crees ae cece ey (CCl ae oa totalsum ~ arr[i]; ocr parent cae tae (Coaren aeeaL ae coo ne COneratee 7 Poon ee Coy Cormeen eer eyFill your code here omen Bc ae Ca ea eS poesia (Ci Oe ae ee Poca cer resctnn pareOnes ae ca Ce (Cri Oe aU Sa ee Shera esh i int result - sum(arr, n); Pov sere sears CH‘tote caret onsnones Oho ries @ nnwcengi 1 Terie 1 lent Gan Cusine Sngeemepunming Snes Ge erence roe compte enoneepi op tte xpSolution 1 PEustreaeserer ts int sum(int a[], int n) { ae ea Ch seat ae aa ae ee ee Sear eae i eee i int main() Ulam cya) oe cae a mee ae mean ae eso eg Be Uesaried Fy i ita = sum(a, n)3 Bee eee eae Eet UT TES Deteatin es ° ‘Single Fle Programming Question obi totement Aes, amat ernst worn rata 9 rogiom that calcustesthepanerataghennumbr Se cede tolmplement futon cae power) ht nk n to parameters th ass ‘umber an tbe poner (p). Heve toe worse ue cay eencs to pero Me caution. ace rapa prompt neuer ener tetas ba nd the poner hy wi olen th np cr prove he power) fcson coe wih the memory eset he base number athe panes. The fuetin prs the pcos cok uations oe update teva the meray aces of tebase nant ie ‘ty, Ale pregrom aplasia of owe nba ia ote power ape ae eters sample question ste roe enutent nputermat: ‘enputconis te bape exponentInput format: The input consists of the base and exponent Output format : The output prints the result. ‘Sample test cases: Input}: 53 whitelist set & ‘Output I: 125atten Esra tees reg Ss Pen e ee Pn Neue a re ee Piracy on uae ee Mea ch see eeo ng eran ee a Yi LE ee ord y int main () { ial aa Cee em ria Pena Ee ea ou Cor ee Cee ay foseceneended ering Cota: cue CP. Cal by Rlence Sots Camct Mortctshed Wd Hrtrsad © Tirasconpied 1 Tnernomited 1 ete Mem Gueclntjpe ShglerleReganming Sine! cet Tos Runetane inne caltyitence —ooretanany Apgy 4)e testcase Posse Comper Messagecept pt ope Toot) ave Complety space Comenty Message cempoten ecmeet cannes pt ae ° sess = complnteneuceet gta pt thet etSolution! Pst ees Cree ss PE Neuter S oy} Taco Pra a Bc che Uees oat power(b, ©); ey} L void poner(int® b, int& e) { int result - 1; while (e > 0) { ee ee C4 y std::cout << result;
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6387)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (634)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1160)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (983)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8302)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (633)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1254)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (10337)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (933)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (887)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (1007)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (3237)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (581)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (297)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (5058)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (943)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4346)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (458)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2091)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1993)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1077)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2780)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (2032)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (2838)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (141)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4086)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (76)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (906)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (813)
Lecture 5 Single File Programming Questions
PDF
No ratings yet
Lecture 5 Single File Programming Questions
12 pages
Lecture 5 Coding Questions
PDF
No ratings yet
Lecture 5 Coding Questions
43 pages
Lecture 8 Single File Programming Questions
PDF
No ratings yet
Lecture 8 Single File Programming Questions
8 pages
Lecture 4 Single File Programming Question
PDF
No ratings yet
Lecture 4 Single File Programming Question
21 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4.5/5 (2369)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
4/5 (277)