Answer to Question #260357 in C for Mr Z

Question #260357

4. Using the online compiler

• Enter the code


int main(int argc, char *argv[]) {
	
	int a, b;
	
	// Obtain values for a and b
	printf("Enter the value for integer a: ");
	scanf("%d", &a);
	printf("Enter the value for integer b: ");
	scanf("%d", &b);
	printf("\n\n");
	
	// Compare a and b
	if (a > b)		      // Testing for a greater than b
	{
		printf("a (%d) is bigger than b 0(%d)\n", a, b);
	}
	else if (a == b)      // Testing for equality
	{
		printf("a (%d) is equal to b (%d)\n", a, b);		
	}
	else				  // Otherwise a must be less than b
	{
		printf("a (%d) is less than b (%d)\n", a, b);		
	}
	
	system("pause");
	return 0;

• Enter a value of a that is greater than b.

• Enter a value of a that is less than b.

• Enter a value of a that is equal to b.

• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code.

• write the message “Password correct” if the value of a is 42 AND the value of b is 216.







1
Expert's answer
2021-11-02T14:42:53-0400
#include <stdio.h>


int main(int argc, char *argv[]) {
	
	int a, b;
	
	// Obtain values for a and b
	printf("Enter the value for integer a: ");
	scanf("%d", &a);
	printf("Enter the value for integer b: ");
	scanf("%d", &b);
	printf("\n\n");
	
	// Compare a and b
    if (a == 42 && b == 216)
    {
        printf("Password correct");
    }
	else if (a > b)		      // Testing for a greater than b
	{
		printf("a (%d) is bigger than b 0(%d)\n", a, b);
	}
	else if (a == b)      // Testing for equality
	{
		printf("a (%d) is equal to b (%d)\n", a, b);		
	}
	else				  // Otherwise a must be less than b
	{
		printf("a (%d) is less than b (%d)\n", a, b);		
	}
	
 	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS