Answers:
Question 1 : 1020
Question 2 : 35
Question 3 : x and y are equal
Explanation:
Question 1:
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:
here, else; consider as empty statement. Because it ends with semicolon(;). That is why the next printf("\n%d",y); is executed.
Question 3:
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!
Three is 3 questions please answer them all Question 1 int main(void) { int x =...
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 = 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 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) { *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) {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) { 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 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 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 *); 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, 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...