1/29
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
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;
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);
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: “);
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);
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");
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.");
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);
Write the binary code for decimal 34
100010
Write the decimal value for binary : 101000001
321
Convert binary (10111001) to hexadecimal
B9
Convert hexadecimal (D7) to binary
11010111
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);
What is the general syntax of a for loop in C?
for (initialization; condition; update) { /* loop body */ }

How many times will the following for loop execute the loop body?
5
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.
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");
}
}
what is the output of codes?
int a, b;
a =15;
b= a%2 + a/4;
printf("%d",b);
4
what is the output of codes?
int a, b;
a =2;
b= (a/4)*10;
printf("%d",b);
0
what is the output of codes?
int a, b;
a =2;
b= (a/4.0)*10;
printf("%d",b);
5
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);
what is the output of codes?
int a, b;
a =2;
b= 3;
int c= (a + b)*(a - b) + 6;
printf("%d",c);
1
How many times will the following while loop execute the loop body?
int i =5;
while (i <=10)
{
// loop body
}
Infinite
How many times will the following while loop execute the loop body?
int i =5;
while (i >10)
{
// loop body
i++;
}
0

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

Which circuit represents an active low LED.
B
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

When executed, the statement
pattern >> 2;
pattern will contain:
0×10
LATD = ~pattern;
The tilde (~) operator performs what operation?
Bitwise “NOT” flips or inverts bits

What is the result of the following bitwise OR operation?
0b11111111
Which of the following correctly sets bit 4 of porwithout changing other bits?