answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
djverab [1.8K]
1 year ago
15

Write a C program that right shifts an integer variable 4 bits. The program should print the integer in bits before and after th

e shift operation. Does your system place 0s or 1s in the vacated bits?
Computers and Technology
1 answer:
Sindrei [870]1 year ago
4 0

Solution :

#include<$\text{stdio.h}$>

#include<conio.h>

void dec_bin(int number) {

$\text{int x, y}$;

x = y = 0;

for(y = 15; y >= 0; y--) {

x = number / (1 << y);

number = number - x * (1 << y);

printf("%d", x);

}

printf("\n");

}

int main()

{

int k;

printf("Enter No u wanted to right shift by 4 : ");

scanf("%d",&k);

dec_bin(k);

k = k>>4; // right shift here.

dec_bin(k);

getch();

return 0;

}

You might be interested in
List any four routes of transmission of computer virus. <br>please give me answer​
JulijaS [17]

Opening attachments or links from unknown or spoofed emails. note: shown above are two examples of how viruses can often appear as legitimate messages, but are designed to trick the computer user. ...

Downloading software from malicious sites. ...

Online Ads. ...

Social media. ...

Unpatched software.

follow me

5 0
2 years ago
B. Write a function that takes one double parameter, and returns a char. The parameter represents a grade, and the char represen
9966 [12]

Answer:

#include <iostream>

#include <cstdlib>

using namespace std;

char grade(double marks){

   if(marks>=90)

   {

       return 'A';

   }

   else if (marks >=80 && marks<90)

   {

       return 'B';

   }

   

   else if (marks >=70 && marks<80)

   {

       return 'C';

   }

   

   else if (marks >=60 && marks<70)

   {

       return 'D';

   }

     else if ( marks<60)

   {

       return 'F';

   }

}

int main()

{

   double marks;

cout <<"Ener marks";

cin >>marks;

char grd=grade(marks);

cout<<"Grae is "<<grd;

return 0;

}

Explanation:

Take input from user for grades in double type variable. Write function grade that takes a parameter of type double as input. Inside grade function write if statements defining ranges for the grades. Which if statement s true for given marks it returns grade value.

In main declare a variable grd and store function returned value in it.

3 0
2 years ago
Which statement accurately describes the clutter feature in outlook 2016
I am Lyosha [343]

Answer:

The answer is the last option

8 0
2 years ago
Write code which takes a user input of a String and an integer. The code should print each letter of the String the number of ti
il63 [147K]

import java.util.*;

public class myClass {

public static void main(String args[]) {

Scanner scan = new Scanner(System.in);

System.out.print("Input a String: ");

String str = scan.nextLine();

System.out.print("Input an integer: ");

int num = scan.nextInt();

for(int i=str.length()-1; i>=0; i--) {

for(int j=0; j<num; j++) {

System.out.print(str.charAt(i));

}

}

}

}

8 0
2 years ago
Write a java program that will print out the following pattern 1 12 123 1234 12345
Ilya [14]

Answer:

public class Main {

  public static void main(String[] args)

{

  int n,m;

  int k=5;

  for(n=1;n<=k;n++)

  {

for(m=1;m<=n;m++)

  System.out.print(m);

   System.out.print(" ");

   }

}

}

Explanation:

The solution to this problem is the use of nested loops of an inner and outer loop to generate a half pyramid of numbers, but displayed on the same line so we have a sequence 1 12 123 1234 12345. The outer loop iterates for n=1 to n<=5 and the inner loop that has the print statement prints the integers from for m = 1 to m<=n.

Note that the value k = 5 is hard coded which in some sense is the number of rows, that is the length of iteration of the outer loop.

5 0
2 years ago
Other questions:
  • 5. You just bought a new hard drive for youYou plan to use this as a secondary hard drive to store allcomputeryour UMA files. On
    8·1 answer
  • In __________ mode, the data within an ip packet is encrypted, but the header information is not.
    15·1 answer
  • Characteristics of a LAN include _____. can be connected to the Internet covers the most area of all networks does not have to b
    5·1 answer
  • Writing in Java, write a program that prompts the user to input an integer and then outputs both the individual digits of the nu
    15·1 answer
  • When you park on a hill, think about which way _____.
    6·2 answers
  • You have verified that all your wireless settings are correct. What is most likely the problem if your laptop has recently been
    7·1 answer
  • Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself."
    10·1 answer
  • Write a function called st_dev. St_dev should have one #parameter, a filename. The file will contain one integer on #each line.
    7·1 answer
  • Write a method called justFirstAndLast that takes a single String name and returns a new String that is only the first and last
    9·1 answer
  • James has created some artwork portraying life on a different planet. He wants to show a world where everything is beautiful and
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!