C Language
C Language
a) Decrease the value of A by 1, decrease the value of B by 1 and divide A from B. Assign the
result to R.
b) Reduce the value of P by 1, then subtract P from Q and then decrease the value of Q by 1.
Assign the result to Z.
c) Increase the value of A and B by 1 and multiply A from B. Assign the result to C.
d) Reduce 1 from A and deduct 1 from B and add A and B. Assign the result to X.
(2*4 =8 Marks)
(2).
a) What is the use of function ‘main()’ in C?
b) What is the use of ‘parameter list” in functions? Provide a suitable example.
c) What is the general format of the Do while? Provide a suitable example.
d) What is the difference between ‘Global’ and ‘Local’ variables?
e) What is the purpose of header files?
(3*5 = 15 Marks)
(3). Determine the output and value of each variable after the execution of each code. All variables
have the value of 2 before execution of each statement
a) printf(“ %d %d ”,++c+x++,c);
b) sum=++sum+c;
c) printf(“%d”, sum+x+c--);
d) printf(“ %d %d %d”,--sum+x , ++c , x);
(2*4 =8 Marks)
Page 1 of 3
(4). Write a program to:
- Input item number, quantity and price for items selected by a customer.
- Casher should enter -99 as item number to get the final total.
- Program should display the bill as mention below.
Customer will get a discount for their total bill as given below:
(14 Marks)
(4) Write a menu driven program in C to process the student data in a class (Use arrays).
Page 2 of 3
(15 Marks)
(8) Write the output of the following programs.
a) b). #include<stdio.h>
#include<stdio.h> void main(){
int c=1,sum=0;
void main(){ while(c!=7)
int i,j=0,c=1; {
while(c<3) sum=sum+c;
{ if(c!=8)
for(i=0;i<=3;i++) {
printf("%d ",++i+j); ++c;
++c; continue;
} }
} else
printf("\n C = %d ",c);
}
printf("\n C = %d ",c);
}
c) .#include<stdio.h> #include<stdio.h>
void main(){ #include<conio.h>
int c; void main(){
int i=1,j=1,x=0;
for(c=6;c>1;c++) switch(i+j-1){
{ case -1:
if(c-1>1) case 0:x=x+1;break;
{ case 1:
c=--c-1; case 3:x=x+2;break;
printf("\n C = %d ",c); default:x=x+3;
} }
else printf(" %d ",x++);
break;
} }
}
e).
#include<stdio.h>
#include<conio.h>
main(){
int i,j=2,sum=0;
for(i=1;i<3;++i)
for(j=0;j<i;j++)
printf("\n i = %d",i+j+1);
printf("\n sum = %d",sum+j);
return 0;
}
(3*5 = 15 Marks)
Page 3 of 3