Question
Three is 3 questions please answer them all
Question 1 int main(void) { int x = 10, y = 20; if (x == y); printf (\n%d %d,x,y); } Output as you would see on the compile

Question 2 int main(void) { int x = 3, y = 5; if (x == 3) printf (\n%d,x); else ; printf(%d, y); return 0; Output as you

Question 3 int main(void) { int x = 3; float y = 3.0; if (x == y) printf (\nx and y are equal); else printf(\nx and y are
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answers:

Question 1 : 1020

Question 2 : 35

Question 3 : x and y are equal

Explanation:

Question 1:

{ 1 #include <stdio.h> 2 int main(void) 3 4 int x=10,y=20; 5 if(x==y); 6 printf(\n%d%d,x,y); 7 8 } L.l. Result $gcc -o main

In this program, compiler will consider the if - statement as bodyless. It will expand the program as bellow,

int main(void)

{

int x=10,y=20;

If(x==y);

{

}

printf("\n%d%d",x,y);

}

Question 2:

1 #include <stdio.h> 2 int main(void) 3- { 4 int x=3, y=5; 5 if(x==3) 6 printf(\n%d,x); 7 else; 8 printf(%d,y); 9 return

here, else; consider as empty statement. Because it ends with semicolon(;). That is why the next printf("\n%d",y); is executed.

Question 3:

1 #include <stdio.h> 2 3 int main(void) 4- { 5 int X=3; 6 float y=3.0; 7 if(x==y) 8 printf(\nx and y are equal D; 9 else 10

Here, we compare if(3==3.0) [if(x==y)] . This condition is satisfied. Because compiler will convert the int (x=3) into float (x=3.0) then compared (3.0==3.0).since int and float cannot be compared. Hence it prints " x and y are equal".

Thank you!

Add a comment
Know the answer?
Add Answer to:
Three is 3 questions please answer them all Question 1 int main(void) { int x =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c program void funcint x, int *y) { 1. Whof the Rings gical ASA All of...

    c program void funcint x, int *y) { 1. Whof the Rings gical ASA All of the above 1.0.2.4) What will be the out of the de int, pat) A) 10 12 (1.03.2) What will be the output of the following int , printf(d, a,b); A) & B) 17 11.12 D) 17.25 13. (L032) An array is a group of memory locations related by the fact that they all have my name and pe A) different different B) same, different...

  • Please help me debug the following code #include int main(void){ int a = 11, b =...

    Please help me debug the following code #include int main(void){ int a = 11, b = 5; int *ptr1 = &a, *ptr2 = &b; printf("%d %d\n", *ptr1, *ptr2); swap(&ptr1, &ptr2); printf("%d %d\n", *ptr1, *ptr2); minimum(ptr1, ptr2); printf("%d %d\n", a, b); return 0; } // Part A void swap(int **ptr1, int **ptr2){ int *temp = *ptr1; *ptr1 = *ptr2; *ptr2 = temp; return; } // Part B void minimum(int *ptr1, int *ptr2){ if(*ptr1 > *ptr2){ *ptr1 = *ptr2; }else{ *ptr2 =...

  • #include<stdio.h> int main() { int i; printf("Type an integer value: "); scanf("%d",&i); evaluate(i); return(0); } void...

    #include<stdio.h> int main() { int i; printf("Type an integer value: "); scanf("%d",&i); evaluate(i); return(0); } void evaluate(int x) { if(x > 10) printf("Value entered by you is greater than 10"); else if(x < 10) printf("Value entered by you is less than 10"); else printf("Value entered by you is equal 10"); } _______________________________________ report for this in hr ?

  • 1. Given this snippet of codes, what is the expected output? void func(int *x, int y)...

    1. Given this snippet of codes, what is the expected output? void func(int *x, int y) {     *x = *x + y;     y = 2; } void main() {     int x = 10, y = 10;     func(&x, y);     printf("x: %d, y: %d", x, y); } x= ? y=? 2. Given this snippet of codes, what is the expected output? void func(int *x, int y) {     *x = *x + y;     x = 10;...

  • What is going to be the output of the following program: # include <stdio.h> int main(void)...

    What is going to be the output of the following program: # include <stdio.h> int main(void) {struct dob {int month; int day; int year;}; struct student {int sid; int yearOfAdmission; float currentGPA; struct dob bday; struct student stdnt = {123, 2015, 8.3, 11, 26, 1993}; printf(" Id is: %d \n", stdnt.sid); printf("Year of admission is: %d \n", stdnt.year OfAdmission); printf("Current GPA is: %.2f\n\n", stdnt.currentGPA); printf("Date of Birth is: %d/%d/%d", stdnt. bday. month, stdnt. bday.day, stdnt. bday.} return 0;}

  • Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void)...

    Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void) { x = x + 2; y = y + 4; } void bar(void) { int x = 10; y = y + 3; foo( ); cout << x << endl; cout << y << endl; } void baz(void) { int y = 7; bar( ); cout << y << endl; } void main( ) { baz( ); } What output does this program...

  • Could you please provide a detailed step by step explanation as to how I should go...

    Could you please provide a detailed step by step explanation as to how I should go about obtaining the output shown for each program fragment. Thanks. a) int f1 (int x) { int y=3; printf("%d%d",x,y); return x++; } int main (void) { int y=6, x=4; printf("%d\n",f1(y)); printf("%d%d\n",x,y); return 0; } OUTPUT: x=6, y=36 x=4, y=6 b) void f2(int n, int a[]) { for (int i=0;i<n;i++) a[i] += a[i+1]; } int main() { int A[]={1,2,3,3,4,5};int i, N=6; for (i=0;i<N;i++) printf("%d ",A[i]);...

  • Question 3 Predict the output of the following C program: #include <stdio.h> void main() { int...

    Question 3 Predict the output of the following C program: #include <stdio.h> void main() { int i = 0; for(; 1; i++){ printf("%d",i); if(i==7) break; } 12pt Paragraph 1 Β Ι Ο Αν και Ta

  • Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int...

    Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...

  • help me 27 28 29 return *a-- * ++*b; void main() { int x = 6,...

    help me 27 28 29 return *a-- * ++*b; void main() { int x = 6, y = 8; x = func(y, y); printf("x - %d, y = %d\n", x, y); X = sub(&y, &y); printf("x = %d, y = %d\n", x, y); } Ans: PART 3 Writing questions [3 marks) 27. (L.0.3.1) Draw a flowchart to accept two number a and b. Find the sum of all odd numbers between a and b. 28. (L.0.4.3) What is the difference...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT