Wednesday 20 January 2016

Quiz 1 (Solution to week 1 Assignment)

Quiz 1

Due on 2016-02-01, 23:55 IST
Answer the following questions. All questions carry equal marks.
Find the output of the following program:
#include<stdio.h>
int main()
{
    int x=10; int y;
    {
        y=x++;
    }
    printf("%d",x);
}
 
 
 
 
Ans. 11
1 point
Find the output of the following program:
#include<stdio.h>
int main()
{
    char c='a';
    switch(c){
        case 97:
            printf("97");
            break;
        case 98:
            printf("98");
            break;
        case 99:
            printf("99");
            break;
        default:
           printf("default");
           
    }
}
 
 
 
 
1 point
Find the output of the following program:
#include<stdio.h>
int main()
{
    int x=10;
    int a=1,b=2,c=3,d=4;
    x+=a=b*c+d-a;
    printf("%d,%d",a,x);
}
 
 
 
 
1 point
What would happen when you compile and run the following program?
#include<stdio.h>
int main()
{
    float a=1.1;
    int b=1.1;
    if(a==b)
        printf("YES");
    else
        printf("NO");
}
 
 
 
 
The program would print NO
1 point
What is the output of the following program?
#include<stdio.h>
int main()
{
    int i,x=10;
    for(i=0;i<2;i++);
    {
        x++;
    }
    printf("%d",x);
}


Ans. 11
1 point
What is the output of the following program?
#include<stdio.h>
int main()
{
    int i=-10;
    if(i){
        printf("1");
    }
    i=0;
    if(i){
        printf("2");
    }
    i=5;
    if(i){
        printf("3");
    }
}

Ans. 13
1 point
Find the output:
#include<stdio.h>
int main()
{
    int x=10;
    do{
        x++;
    }while(x++ > 12);
    printf("%d",x);
}
 
 
 
 
1 point
Find the output:
#include<stdio.h>
void main(){  
  int a=22;  
  a=a>>4;  
  printf("%d",a);   
}  
 
 
 
 
1 point
Find the output:
#include<stdio.h>
void main(){
  int a,b;
  a=3,1;
  b=(5,4);
  printf("%d",a+b);
} 
 
 
 
 
1 point
Which of the following condition checks when inserted in place of CONDITION will print 10 twice?
#include<stdio.h>
void main(){
 int a=10;
 if(CONDITION)
   printf("\n%d",a);
 else
   printf("\n%d %d",a,a);
}
 
 
 
 
 
1 point
What will the following program print?
#include<stdio.h>
int main ( )
{
  int a=5;
  int b = a % ( aa/2 )  ( a  3 ) + a ;
  printf(”%d”,b);
  return 0 ;
} 

Ans. 9
1 point
What will be the output printed by the printf statement in the following code segment?
  char a,b,c;
  a = 'b';
  b = 'c';
  c = 'A';
  b=c;c=b;
  a=c;c=a;
  printf("A%cB%cC%c",a,b,c);
 
 
 

2 comments:

  1. Replies
    1. I HAVE WRITTEN THE ANSWERS BUT I THINK THERE WAS SOME PROBLEM .UPLOADING THEM AGAIN.

      Delete