Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

  Take Quiz (Monsoon) Beta Version !!
  Do You have Qs. in your Mind ??? Ask it as Qs. or MCQs or create it as polling Live Now !!

Programs Questions and Answers



    311 / 348

    Write a program using command line argument to input two number and Calculate the Sum of numbers.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   JAVA  
     
    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char * argv[])
    {
      int x,y;
      if (argc == 1 || argc > 3)
      {
        printf("Enter Two Number\r\n");
        exit(0);
      }
      x=atoi(argv[1]);
      y=atoi(argv[2]);
      printf("\nSum of two number %d and %d is : %d\r\n",x,y,x+y) ;
    return 0;
    }

    Tags:TCS

    312 / 348

    Write a program using command line argument to input a string and print the string in reversed order..

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   JAVA  
     
    #include<stdio.h>
    int main()
    {
        char a[50];
        int l,i=0,j,temp;
        printf("Enter A String: ");
        gets(a);
        for(l=0;a[l]!='\0';l++); 
                 // to determine length of String
        j=l-1;   // l is the length of String
        for(i=0;i<l/2;i++)
        {
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
            j--;
        }
        puts(a);
        return 0;
    }

    Tags:TCS

    313 / 348

    Write a program using command line arguments to input a number and find that number is even or odd. INPUT: 14 OUTPUT: Even INPUT: 13 OUTPUT: Odd

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   JAVA  
     
    #include<stdio.h>
    int main(int argc,char *argv[])
    {
        int i;
        if(argc==2)
        {
            if(atoi(argv[1])%2==0)
                printf("\nEVEN NO.\n");
            else
                printf("\nODD NO.\n");
         }
        else if(argc>2) 
            printf("\nEnter only one Integer..!!!\n");
        else 
            printf("\nEnter one Integer.!!!\n");
        return 0;


    }

    Tags:TCS

    314 / 348

    Write a program using command line arguments to input two number and find the GCD/HCF of the number. Condition: If the entered number is less than 2 print the message and exit.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   JAVA  
     
    #include<stdio.h>
    int main(int a,char *b[])
    {
        int num1,num2,min,i,gcd=1;
        if(a!=3){
            printf("Enter two argument\n");
            exit(1);
        }
        num1=atoi(b[1]);
        num2=atoi(b[2]);
        min=(no1<no2)?no1:no2;
        for(i=1;i<=min;i++)
        {
            if((num1%i)==0 && (num2%i)==0)
                gcd=i;
        }
        printf("GCD of two number %d",gcd);
        return 0;
    }

    Tags:TCS

    315 / 348

    Write a program using command line arguments to input two number and find the LCM of the number. Condition: If the entered number is less than 2 print the message and exit.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   JAVA  
     
    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char * argv[])
    {
      int n1,n2,x,y;
      if (argc == 1 || argc > 3)
      {
        printf("Enter Two Number\r\n");
        exit(0);
      }
      x=atoi(argv[1]);
      y=atoi(argv[2]);
      n1 = x; n2 = y;
      while(n1!=n2){
          if(n1>n2)
               n1=n1-n2;
          else
          n2=n2-n1;
      }
      printf("L.C.M of %d & %d = %d \r\n",x,y,x*y/n1);
      return 0;
    }

    Tags:TCS

    316 / 348

    Write a program using command line argument to input one number and print the Factorial of the number.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   JAVA  
     
    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char * argv[])
    {
        int  fact = 1,c = 0, num = 0;
        if(argc == 1 || argc > 2)
        {
             printf("Enter the number \n");
             exit(1);
        }
        num = atoi(argv[1]);
        for (c = 1; c <= num ; c++)
            fact *= c;

      printf("Factorial of %d = %d\n", num, fact);

    return 0;
    }

    Tags:TCS

    317 / 348

    Write a C program using command line arguments which will take numbers as input and Find the average of the numbers.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C  
     
    #include <stdio.h>

    int main(int argc, char * argv[])
    {
        int  sum = 0,i = 1,count = 0;
        if(argc == 1)
        {
             printf("Enter the number \n");
             exit(1);
        }
        count = argc - 1;
        while (i <= count )
        {
           sum += atoi (argv[i]) ;
           i++;
        }
          printf("Avg of the numbers.%d\n", sum/count);
    }

    Tags:TCS

    318 / 348

    Write a program in C using command line argument to input one number and print the square root of the number without using sqrt().

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C  
     
    #include <stdio.h>
    #include <stdlib.h>

    int SqrtOfNumber (int);

    int main(int argc, char * argv[])
    {
        int  temp = 0;
        if(argc == 1 ||  argc > 2)
        {
             printf("Enter the number \n");
             exit(1);
        }
        temp = atoi (argv[1]) ;
        printf("Sqrt of the num. %d = %d\n", temp, SqrtOfNumber(temp));
    }

    int SqrtOfNumber (int num)
    {
        int i = 1, result = 1;

        if (num == 0 || num == 1)
           return num;

        while (result < num)
        {
           if (result == num)
              return result;
           i++;
           result = i*i;
        }
        return i-1;
    }

    Tags:TCS

    319 / 348

    Write a program in C using command line argument to print Your Name Using Command Line Argument.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C  
     
    #include<stdio.h>
    int main(int argc, char * argv[])
    {
          int i;
          if(argc==1)
          {
                printf("You need to enter your name");
                exit(1);
          }
          for(i=1;i<argc;i++)
          {
                printf("%s",argv[i]);
          }
          return 0;
    }

    Tags:TCS

    320 / 348

    Write a program in C using command line argument to input one number and print Sum of digits of number.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C  
     
    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char * argv[])
    {
        long num, temp, digit, sum = 0;
        if(argc == 1 ||  argc > 2)
        {
             printf("Enter the number\n");
             exit(1);
        }
        num = atoi (argv[1]) ;
        temp = num;
        while (num > 0)
        {
            digit = num % 10;
            sum  = sum + digit;
            num /= 10;
        }
        printf("Sum of the digits of %ld = %ld\n", temp, sum);
    }

    Tags:TCS