Canna

Sunday, 23 September 2018

IO 10

Problem Description

Sneha got a single integer as an input , and her task to perform all assignment operations in with the given input . Let us help her to solve with the following conditions met,

To Perform , 

Assign an input the new the variable and display
Using addition assignment operation(c+=3;c=c+3)
Using Subtraction assignment operation
Using division assignment operation
Using modulus assignment operation
Input and Output Format:

Refer sample input and output for formatting specification.

All float values are displayed correct to 2 decimal places.

All text in bold corresponds to input and the rest corresponds to output.


  • Test Case 1

    Input (stdin)
    3
    
    
    Expected Output
    c=3
    
    c+=6
    
    c-=3
    
    c*=9
    
    c/=3
    
    c%=0
  • Test Case 2

    Input (stdin)
    7
    
    
    Expected Output
    c=7
    
    c+=14
    
    c-=7
    
    c*=49
    
    c/=7
    
    c%=0
  • Program
  • #include <stdio.h>
    int main()
    {
      int c,d,e,f,g,h;
      scanf("%d",&c);
      printf("c=%d\n",c);
      d=c+c;
      printf("c+=%d\n",d);
      h=d-c;
      printf("c-=%d\n",h);
      e=c*c;
        printf("c*=%d\n",e);
      f=e/c;
      printf("c/=%d\n",f);
      g=f%c;
      printf("c%%=%d",g);
      
        
        
    
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.