Digital 1 exam

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:32 PM on 4/18/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

30 Terms

1
New cards

Using a single C statement, define a variable to hold a pressure  as an integer data type that can hold values in the range of 0 to 200 inclusive using the smallest data type available.

unsigned char pressure;

2
New cards

Using a single C statement, print the message 'The product is' followed by the value stored in the float variable named result.

printf(“The product is %f”, result);

3
New cards

Using a single C statement, prompt the user to enter an integer. End your prompt with a colon (:) followed by a space and leave the cursor positioned after the space.

printf(“please enter an integer: “);

4
New cards

Using a single C statement, read an integer from the keyboard and store the value entered into an integer variable named highLimit.

scanf(“%d”, &highLimit);

5
New cards

Print the message "This is a C program." on one line. Leave the cursor on the next line.

printf("This is a C program.\n");

6
New cards

Print the message "This is a C program." on two lines so that the first line ends with C. Leave the cursor beside the period.

printf("This is a C\nprogram.");

7
New cards

Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the sum of the two values.

int num1, num2;
int sum;

printf("Enter 2 numbers: ");
scanf("%d %d", &num1, &num2);

sum = num1 + num2;

printf("sum = %d", sum);

8
New cards

Write the binary code for decimal 34

100010

9
New cards

Write the decimal value for binary : 101000001 

321

10
New cards

Convert binary (10111001) to hexadecimal

B9

11
New cards

Convert hexadecimal (D7) to binary

11010111

12
New cards

Write a C program that uses a while loop to calculate and print the sum of all integers from 1 to 100.

int sum = 0;
int i = 1;

while (i <= 100)
{
sum = sum + i;
printf("the sum currently %d:", sum);
i++;
}

printf("the total sum is %d", sum);

13
New cards

What is the general syntax of a for loop in C?

for (initialization; condition; update) { /* loop body */ }

14
New cards
<p>How many times will the following for loop execute the loop body?</p><p></p><p></p><p></p>

How many times will the following for loop execute the loop body?

5

15
New cards

What is the primary difference between a while loop and a for loop in C?


For loops have initialization, condition, and update steps combined in one line.

16
New cards

Print the integers from 1 to 48 inclusive using a for loop and the counter variable named x. Assume that the variable x has been defined, but not initialized. Print only sixteen integers per line. [Hint: Use the calculation x Modulo (%) 16. When the remainder of this is 0, print a newline character, otherwise print a space character.]

for (int i = 1; i <= 48; i++)

{

printf("%d ", i);

if (i % 16 == 0)

{

printf("\n");

}

}

17
New cards

what is the output of codes?

int a, b;

a =15;

b= a%2 + a/4;

printf("%d",b);

4

18
New cards

what is the output of codes?

int a, b;

a =2;

b= (a/4)*10;

printf("%d",b);

0

19
New cards

what is the output of codes?

int a, b;

a =2;

b= (a/4.0)*10;

printf("%d",b);

5

20
New cards

Write a C program that prompts the user to input two integers (3-9 inclusive) from keyboard, then print the sum of these two integers.  If any of the two integers is out of range, the program should re-prompt user to re-enter two integer until two integers are both in the range.

int num1, num2;

do
{
printf("Please enter 2 numbers from 3–9: ");
scanf("%d %d", &num1, &num2);

} while (num1 < 3 || num1 > 9 || num2 < 3 || num2 > 9);

printf("Sum = %d", num1 + num2);

21
New cards

what is the output of codes?

int a, b;

a =2;

b= 3;

int c= (a + b)*(a - b) + 6;

printf("%d",c);

1

22
New cards

How many times will the following while loop execute the loop body?

int i =5;

while (i <=10) 
    {
    // loop body
    }

Infinite

23
New cards

How many times will the following while loop execute the loop body?

int i =5;

while (i >10) 
    {
    // loop body

    i++;
    }

0

24
New cards
<p><span>When the pushbutton is pressed, what logic level would be read by the Input pin?</span></p>

When the pushbutton is pressed, what logic level would be read by the Input pin?

0

25
New cards
<p>Which circuit represents an active low LED.</p>

Which circuit represents an active low LED.

B

26
New cards

if( SW0_RC0_GetValue( ) = 0 )
            {
            pattern = (pattern << 1);
            }

The code block attached to the if statement will execute when:

The attached active low switch is closed

27
New cards
<p>When executed, the statement<br><br>pattern &gt;&gt; 2;</p><p>pattern will contain:</p>

When executed, the statement

pattern >> 2;

pattern will contain:

0×10

28
New cards

 LATD = ~pattern;

The tilde (~) operator performs what operation?

Bitwise “NOT” flips or inverts bits

29
New cards
<p>What is the result of the following bitwise OR operation?</p>

What is the result of the following bitwise OR operation?

0b11111111

30
New cards

Which of the following correctly sets bit 4 of  porwithout changing other bits?