Given INT x, y, z, M x 2:, y 12; z-3; Solve for M using the operator precedence
ID: 3754795 • Letter: G
Question
Given INT x, y, z, M x 2:, y 12; z-3; Solve for M using the operator precedence for the C programming language. Do not use a calculator. 1. M xy/z Solve for M 2. M.lx+z)%x Solve for M 3. M x y)/z Solve for M 5. M-y/+z) Solve for M 6. The equation t-t+ 1 can be written in two different condensed formats in C. What are they? 7. Use the integer values,m 22 and n 6 to compute the following: b) m/n Given the following partial program, Rrintti"j is %d ", ++)); 8. What value for j will be displayed on the monitor? What value for j will be displayed on the monitor? printi") is %d ", j); 9. Given the following partial program, m 1 What value for m will be displayed on the monitor? printf"m is %dn", m); What value for m will be displayed on the monitor?Explanation / Answer
1ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,M;
clrscr();
x=2;
y=12;
z=3;
M=x+y/z;
printf("M is: %d ",M);
getch();
}
output:
M is : 6
2ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,M;
clrscr();
x=2;
y=12;
z=3;
M=(y+z)%x;
printf("M is: %d ",M);
getch();
}
output:
M is: 1
3ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,M;
clrscr();
x=2;
y=12;
z=3;
M=(x+y)/z;
printf("M is: %d ",M);
getch();
}
output:
M is: 4
4ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,M;
clrscr();
x=2;
y=12;
z=3;
M=y%(x+z);
printf("M is: %d ",M);
getch();
}
output:
M is:2
5ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,M;
clrscr();
x=2;
y=12;
z=3;
M=y/(x+z);
printf("M is: %d ",M);
getch();
}
output:
M is : 2
6 ans)
two different formats are to be t++,++t which are called as post increment and pre increment respectively.
7 ans)
a)
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n;
clrscr();
m=22;
n=6;
printf("ans is: %d ",(m%n));
getch();
}
output:
ans is :4
b)
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n;
clrscr();
m=22;
n=6;
printf("ans is: %d ",(m/n));
getch();
}
output:
ans is :3
8 ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int j;
clrscr();
j=1;
printf("j is %d ",++j);
printf("j is %d ",j);
getch();
}
output:
j is 2
j is 2
9 ans)
#include<stdio.h>
#include<conio.h>
void main()
{
int m;
clrscr();
m=1;
printf("m is %d ",m++);
printf("m is %d ",m);
getch();
}
output:
m is 1
m is 2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.