Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. (20 points) Here are four C programs that come the bits ou in an integer; that is, you num ' ch 5 ' and

image text in transcribed
6. (20 points) Here are four C programs that come the bits ou in an integer; that is, you num ' ch 5 ' and it will print ' 2 ' (because 5 in binary is - 101, and two bits are turned on). For each program, indicate whether it works. If it does not, show how to fix it by changing the fereest characters possible. Note that these progratns will crash if not given an argument; that's not considered an error per the design spec. Program A [. Works as is. Needs fixing. \#include \#include stdilb.h> int main(int arge, char *argu[]) i. // warning: assumes argv [1] ! int val=ato1(argv[1]); int sum=0; for (int 1=0;1=0;i ) if (val \& 11 ) sum +=1; printf ("\%d ", sum); \} Program C Works as is. Needs fixing: \#include \#include stdlib. h> int main(int argc, char *argv[) 1 // warning: assumes argv [1]! int val = atoi(argv[1]); int sum=0; while (val) \{ if ( val

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What is the raison-dtre behind pricing of a depositary receipt?

Answered: 1 week ago