Sie sind auf Seite 1von 8

Assignment - 1

Computational Engineerin - Theory

Posted on: August 17, 2019


Strict Deadline: August 23, 2019
Objectives: After completing the assignment, the student will be able to ..

1. Understand all the operators in C.

2. Understand precedence and associativity.

3. Evaluate any arithmetic expressions.

4. Differentiate and convert between number systems.

5. Understand the need and usefulness of various number systems.

6. Read and trace a C program.

7. Understand the representation of numbers in the memory.

8. Understand the three types of errors and able to resolve them.

I. Operators:

Q1: Identify the set of all operators in C and write the associativity and
precedence for each with an example.
II. Expression Evaluation:

Q2: The initial value for variables used are as follows,


Result=2, a=2 ,b=3, c=4, d=1, e=3, f=4, g=4, h=7. Evaluate the expres-
sion Result += a+b-c+e*f/g%h. What is the value stored in each variable
at the end of evaluation?

2
III. Number System:

Q3: Convert (11111)10 to base 2,8,16 and (10101010)2 to base 10,8,16.

Q4: Convert (ABCDEF)16 to octal and decimal representations.

3
Q5: Represent the octal number 101110 in decimal and hexadecimal.

Q6: From the figure below. ’D’ understands base 2, ’B’ knows binary and
hexadecimal, ’C’ knows bases 2, 10, 16 and ’A’ only understands decimal.
’D’ can communicate with ’B’, ’C’ and C with ’A’ as in the figure. Now,
when ’D’ receives a number from ’A’ through ’C’, it gets the number stored
in ’B’ and communicates it to ’A’ with proper intermediate number system
conversions. The value received by ’D’ is (10011)2 and the value stored in
’B’ is 9858.

C
10011 D A

B 9858

1. What is the value send by ’A’ to ’D’ ?

2. Perform number system calculations between all possible communica-


tions, starting from ’A’ to ’B’ through ’C’ & ’D’ and back to ’A’ through
’C’ & ’D’.

4
IV. Find the Output:

Q7: What is the output of the program? Explain your answer in two or
three lines.
#include<stdio.h>
void main()
{
char str1=-1;
signed char str2=-1;
unsigned char str3=-1;
printf(”%d and %d and %d”, str1,str2,str3);
}

5
Q8: What is the output of the program? Explain your answer in two or
three lines. The input to be given is 5 and 10.
#include<stdio.h>
void main()
{
int num1,num2;
num3 = num1 + num2
scanf(”%d%d”,&num1,&num2);
printf(”The sum of %d and %d is”, num1,num2,num3);
}

Q9: What is the output of the program? Explain your answer in two or
three lines. The input to be given is 5 and 10.
#include<stdio.h>
void main()
{
int num1,num2;
scanf(”%d%d”,num1,num2);

6
if(num1>num2)
printf(”The number %d is greater than %d”, num1,num2);
else
printf(”The number %d is greater than %d”, num2,num1);
}

Q10: What is the output of the program? Explain your answer in two
or three lines. The number to be given as input is 10.
#include<stdio.h>
void main()
{
int num1;
scanf(”%d”,&num1);
if(num1%2 == 0)
printf(”The number %d is divisible by 3”, num1);
else
printf(”The number %d is divisible by 2”, num1);
}

7
8

Das könnte Ihnen auch gefallen