B.V.
M ENGINEERINGCOLLEGE (AUTONOMOUS INSTITUTE)
B.E 1ST YEAR (1ST SEM) ELECTRONICS & TELECOMMUNICATION
MID SEMESTER EXAMINATION
SUBJECT: COMPUTER PROGRAMMING (CC121)
Date: 18/10/2016 Time: 11:00 AM to 12:00 AM
Total Marks: 30
Instructions:
Figure to the right shows the marks.
Use pencil & scale whenever necessary.
Q.1 is compulsory & attempts any two questions from Q.2, Q.3 and Q.4.
Q.1 Find the output of following code. [10]
1) main() (2)
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf(“%d %d\n”,x,y);
}
2) main() (2)
{
int x=5,i=5;
printf(“%d%d%d%d%d%d”,i++,i--,++i,--i,i);
printf(“%d %d %d\n”,x,x<<2,x>>2);
}
3) main() (2)
{
int i=-1,j=-1,k=0,l=2,m;
m=i++ && j++ && k++ || l++;
printf(“%d %d %d %d %d”,i,j,k,l,m);
}
enum colors {BLACK,BLUE,GREEN} (1)
4)
main()
{
printf(“%d..%d..%d”,BLACK,BLUE,GREEN);
return(1);
}
5) main() (1)
{
int i=-1;
+i;
printf(“i = %d, +i = %d \n”,i,+i);
}
6) main() (1)
{
int k=1;
printf(“%d==1 is %s”, k , k==1?“TRUE“:”FALSE”);
}
main() (1)
7)
{
int i=5;
printf(“%d”,i=++i ==6);
}
Q.2 (A) What do you mean by ternary operator? Write following code using [2]
ternary ? Operator.
if(a>10)
if(a<20)
cost=100;
else cost=150;
else cost=50;
(B) What is the difference between 32-bit and 64-bit operating system? [3]
Also give the difference between compiler and interpreter.
(C) W.A.P to read three numbers from the keyboard & find out minimum [5]
out of these three using if….else nested structure.
Q.3 (A) Why ‘C’ language is called middle level language? [2]
(B) Explain implicit and explicit type conversion using suitable examples. [3]
(C) W.A.P to read and display following table of data. The Name and Code [5]
must be left-justified and Price must be right justified.
Name Code Price
Fan 67831 1234.50
Motor 450 5786.70
Q.4 (A) Write a size & range of following data types on a 16-bit machine. [2]
1) signed char 2) unsigned short int 3) float 4) long double
(B) W.A.P to check entered character is vowel or not using switch case [3]
statement.
(C) (a) Find the output of following program. [3]
void main()
{
char s1[30]=”DHARMSINH DESAI UNIVERSITY”;
int x=67584;
float y=95.7658;
printf(“%.6s\n”,s1);
printf(“%7s\n”,s1);
printf(“%010d\n”,x);
printf(“%10d\n”,-x);
printf(“%-7.2f”,y);
printf(“%*.*f\n”,7,2,y);
printf(“%e\n”,y);
printf(“%12.4e\n”,-y);
} [2]
(b) State the output produced by following printf() statement.
1) printf(“%2d %c %4.2f”,1234,’x’,1.23);
2) printf(“%d\t %4.2f”,1234,456);
3) printf(“%10dxxxx%5.2f”,1275,-235.74);
4) printf((“%-10d %-15s”,1275,”CAMBRIDGE");
WISH YOU A VERY HAPPY DIWALI
B.V.M ENGINEERINGCOLLEGE (AUTONOMOUS INSTITUTE)
B.E 1ST YEAR (1ST SEM) ELECTRONICS & TELECOMMUNICATION
MID SEMESTER EXAMINATION
SUBJECT: COMPUTER PROGRAMMING (CC121)
Date: 16/12/2016 Time: 09:00 AM to 10:00 AM
Total Marks: 30
Instructions:
Figure to the right shows the marks.
Use pencil & scale whenever necessary.
Q.1 is compulsory & attempts any two questions from Q.2, Q.3 and Q.4.
Q.1 State whether following statements are true or false. [10]
Justify your answer.
1) The scanf() function can be used to read only one value at a
time.
2) The expression !(x<=y) is same as the expression x>y.
3) The format specification %5s will print only the first 5 characters
of given string to be printed.
4) The default case is required in the switch statement.
5) An exit-controlled loop is executed a minimum of one time.
Q.2 (A) Draw only block diagram of computer system. [2]
(B) Draw a flowchart to reverse a given number. [3]
(C) W.A.P to read three numbers from the keyboard & find out [5]
maximum of these three using if….else nested structure.
Q.3 (A) W.A.P to generate following pattern. [2]
1
12
123
……….
(B) Explain implicit and explicit type conversion using suitable [3]
examples.
(C) W.A.P to generate multiplication table using do…. While [5]
loop.
Q.4 (A) How enumeration variables are declared? What is the [2]
advantage of using them in a program?
(B) Draw a flowchart of process of compiling and running a C [3]
program.
(C) (a) Find the output of following program. [3]
void main()
{
char s1[20]=”BVM ENGG COLLEG”;
int x=12345;
float y=98.7654;
printf(“%20.10s\n”,s1);
printf(“%.7s\n”,s1);
printf(“%010d\n”,x);
printf(“%-10d\n”,x);
printf(“%-7.2f”,y);
printf(“%*.*f\n”,7,2,y);
printf(“%e\n”,y);
printf(“%-10.2e\n”,-y);
}
(b) What is prefix and postfix increment operators? Also [2]
find the output of following code.
void main()
{
I nt b, a=5;
a++;
b=a++;
b++;
b=++a;
printf(“%d %d”,a,b);
}
BEST OF LUCK