Quiz II: Computer Programming (MA511) : 1), For Unsigned Int: (0 To 2 1)
Quiz II: Computer Programming (MA511) : 1), For Unsigned Int: (0 To 2 1)
1. What is the difference between the constants 123, ‘1’, and “123” ? [1]
3. What is the line #include< stdio.h > at the top of a C source file for ? [1]
its an invalid expression since at the same time i is increasing and assigning to itself.
Ans.
5. What are the largest and smallest values that can be reliably stored in a variable of type
signed int and unsigned int in a 8 bit machine ? [2]
6. Under what conditions will this code print (i) water (ii) steam ? [2]
if(T < 32)
printf(“ice\n”); Ans:
else if(T < 212) (i) water :32 ≤ T < 212
printf(“water\n”); (ii) steam :212 ≤ T
else printf(“steam\n”);
7. What would this code print ? [2]
Ans:
int i;
a
for(i = 0; i < 3; i = i + 1)
a
printf(“a\n”);
a
printf(“b\n”);
b
printf(“c\n”);
c
8. Write a C program to find out how many of the numbers from 1 to 777 are greater than 7
and divisible by 7 ? [2]
#include < stdio.h >
main(){
int i, count=0;
for(i = 0; i <= 777; i = i + 1){
if((i > 7)&&(i%7 == 0)){
Ans. count=count+1;
//printf (“%d, %d\n”, i, count);
}
}
printf (“%d\n”, count);
}
9. Write a C program to compute the average of the numbers (x) which are perfect square and
x ∈ [1, 1024] ? [2]
10. Write a program that takes a line of string as input and print the line in reverse order. [2]