Beruflich Dokumente
Kultur Dokumente
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:
2
III. Number System:
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
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