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.

Programs Questions and Answers



  • 1. Write code for swapping two variables without using 3rd variable.

    Input : ,   Output :

  • Answer In: C   C++   PHP  
     
    #include<stdio.h>
    #include<conio.h>
    # include <iostream>
    using namespace std;
    main()
    {
    int a=10, b=20;
    clrscr();
    cout<<"Before swap is:"<<a<<"\t"<<b;
    a=a+b;//a=30 (10+20)
    b=a-b;//b=10 (30-20)
    a=a-b;//a=20 (30-10)
    cout<<"\nAfter swap" <<a<<"\t"<<b;
    getch();
    }
    Tags:

    Wipro TCS Syntel Inc. 

  • 2. Write a program to print prime numbers upto 10.

    Input : ,   Output :

  • Answer In: C   C++   PHP  
     
    #include<stdio.h>
    # include <iostream>
    using namespace std;
    void main()
    {
         int n,i,j,ct=0; 
        cout << "Enter any number \n";
         cin>>n;
         cout << " All prime numbers are -\n";
         for(i=2;i<=n;i++)
         {
                 ct=0;
                 for(j=2;j<i;j++)
                 {
                         if(i%j==0)
                         {
                                   ct=1;
                                   break;
                         }
                 }
                 if(ct==0)
                 {
                     cout << i;
                 }
         }
         getch();
    }
    Tags:

    Wipro TCS Syntel Inc. 

  • 3. Write a program to print the nth fibonacci number.

    Input : ,   Output :

  • Answer In:
     No Discussion on this question yet!
    Tags:

    Cisco TCS Syntel Inc. 

  • 4. Write a program to print odd number in descending order from 1-10.

    Input : ,   Output :

  • Answer In:
     No Discussion on this question yet!
    Tags:

    TCS 

  • 5. Write a Program to generate random numbers.

    Input : ,   Output :

  • Answer In: C  
     
    #include <stdio.h>
    #include <stdlib.h>
     
    int main() {
      int c, n;
     
      printf("Ten random numbers in [1,100]\n");
     
      for (c = 1; c <= 10; c++) {
        n = rand() % 100 + 1;
        printf("%d\n", n);
      }
     
      return 0;
    }
    Tags:

    TCS 

  • 6. Write a program using command line argument to input a word and check whether it is palindrome or not.

    Input : ,   Output :

  • Answer In: C  
     
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    void isPalindrome(char str[])
    {
        int l = 0;
        int h = strlen(str) - 1;

        while (h > l)
        {
            if (str[l++] != str[h--])
            {
                printf("%s is Not Palindromen \r\n", str);
                return;
            }
        }
        printf("%s is palindromen\r\n", str);
    }

    int main(int argc, char * argv[])
    {
      if (argc == 1 || argc > 2)
      {
        printf("Enter String \r\n");
        exit(0);
      }

      isPalindrome(argv[1]);
    return 0;
             
    Tags:

    TCS 

  • 7. Write a C program which will check whether a given number N is prime or not. 
    
    If the number N is prime, then find its square root and print that value to stdout as floating point number with exactly 2 decimal precision. 
    
    If the given number N is not prime, then print the value 0.00 to stdout. 
    
    The given number N will be a positive non Zero integer and it will be passed to the program using the first command line parameter. Other than the floating point result, no other information should be printed to stdout.

    Input : ,   Output :

  • Answer In: C  
     
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>

    int main(int argc, char * argv[])
    {
      int n, i, flag = 0;
      double x;

      if (argc == 1 || argc > 2)
      {
        printf("Enter String \r\n");
        exit(0);
      }

        n = atoi(argv[1]);
        x = n;
        for(i=2; i<= n/2; ++i)
        {
            if(n%i == 0)
            {
                flag=1;
                break;
            }
        }
        if (flag==0)
            printf("%.2lf \r\n", sqrt (x) );
        else
            printf("%.2lf \r\n",0.00);
    return 0;
    }

    Tags:

    TCS 

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

    Input : ,   Output :

  • Answer In: C  
     
    #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 

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

    Input : ,   Output :

  • Answer In: C  
     
    #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 

  • 10. 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 : ,   Output :

  • Answer In: C  
     
    #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