Submitted Questions

  • Accept two numbers from the user...

    ...and multiply these two numbers without using the multiplication operator! using any loop!

    Delbin

    • Jul 22nd, 2012

    Code
    1. #include<stdio.h>
    2. #include<stdlib.h>
    3. main()
    4. {
    5.         int a,b,result=0;
    6.         scanf("%d%d",&a,&b);
    7.         while(a)
    8.         {
    9.                 result=result+b;
    10.                 a--;
    11.         }
    12.         printf("%d
    13. ",result);
    14. }

  • write a program to accept 20 numbers from the user

    And count how many positive and how many negative and 0 numbers were entered!! pls

    delbin

    • Jul 22nd, 2012

    Code
    1. #include<stdio.h>
    2.  
    3. main()
    4. {
    5.         int a[20],i;
    6.         int pos,neg,zero;
    7.  
    8.         pos=neg=zero=0;
    9.  
    10.         for(i=0;i<5;i++)
    11.         {
    12.                 scanf("%d",&a[i]);
    13.                 if(a[i]>0)
    14.                         pos++;
    15.                 else if(a[i]<0)
    16.                         neg++;
    17.                 else
    18.                         zero++;
    19.         }
    20.         printf("+:%d -:%d 0:%d
    21. ",pos,neg,zero);
    22.  
    23. }