In an assignment given on CSE211, a student is assigned the following task
3. Consider PC = last digits of your registration no(i.e 69)
4. Place your date of birth including your date and month of birth(i.e 20 oct 2000) into the DR
eg: 0108 – 01 date and 08 as month
5. Now perform the below given task
AR PC
M[AR] DR
IR M[AR]
Explain the contents of the memory after the execution of second instruction.
// ----- C code -----
#include <stdio.h>
int main(void) {
printf("Enter the number: ");
int n;
scanf("%d",&n);
if(n>89 && n<101){
printf("Grade: A");
}
else if(n>79 && n<90){
printf("Grade: B");
}
else if(n>69 && n<80){
printf("Grade: C");
}
else if(n>59 && n<70){
printf("Grade: D");
}
else if(n<60){
printf("Grade: E");
}
return 0;
}
Output :
// ----- C++ Code -----
#include <iostream>
using namespace std;
int main(void) {
cout<<("Enter the number: ");
int n;
cin>>n;
if(n>89 && n<101){
cout<<("Grade: A");
}
else if(n>79 && n<90){
cout<<("Grade: B");
}
else if(n>69 && n<80){
cout<<("Grade: C");
}
else if(n>59 && n<70){
cout<<("Grade: D");
}
else if(n<60){
cout<<("Grade: E");
}
return 0;
}
Output:
Comments
Leave a comment