(a)
Writing a program that takes a decimal number input from the user and displays its binary number equivalent in 12 bits on the screen.
For example:
Enter a decimal number: 32
Its Binary Equivalent is : 000000100000
Hints
Conversion to base (2) is accomplished by successive divisions by 2. Make use of a loop for successive divisions.
Make use of %( modulus) and / (divide) operators (binary) to get the results.
(b)
Creating a program that declares an integer array with five elements. Now store in that integer array five different elements (10,20,30,40,50) using a pointer variable only.
Hints
The identifier of an array is equivalent to the address of its first element, as a pointer is equivalent to the address of the first element that it points to.
If A[5] is an array then the expressions A[2] and *(A+2) designate the same thing. Use (*A+2) to store the value in the third element of array.
C or C++ programing?
I'd do both in C, and do both by myself, rather than cheat on the assignment. The reason is that I would want to become a competent programmer who is really able to do things. Such programmers make good money, but companies aren't interested in paying people who can't do anything.
Reply:do your own homework
Reply:Tricky. I'm going with C++
Reply:you should first devid your number by ten (you can do it by a loop).and every digit you reached print it on the screen.
if you want the program i can write it for you.so mail me to send it for you as free.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment