Question: 6. (20 points) Here are four C programs that come the bits ou in an integer; that is, you num ' ch 5 ' and
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
Get step-by-step solutions from verified subject matter experts
