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...

Programs Questions and Answers



    Question :: 1
    Write a program to print next to the last word of a sentence.

    Input : What is your name


    Output : your

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Experience
    Answer In: C   C++   JAVA   PHP  
     
    <p>import java.io.BufferedReader;<br />
    import java.io.IOException;<br />
    import java.io.InputStreamReader;</p>

    <p>public class StringWordIBM <br />
    {</p>

    <p>    public static void main(String[] args) throws IOException <br />
        {<br />
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));<br />
            String str;<br />
            System.out.println("Enter the String : ");<br />
            str=br.readLine();<br />
            System.out.println(str);<br />
            String s[] = str.split(" ");<br />
            System.out.println("Splitted string : ");<br />
            for(int i=0;i<s.length;i  )<br />
            {<br />
                System.out.println(s[i]);<br />
                <br />
            }<br />
            System.out.println("Second Last word of String is : " s[s.length-2]);<br />
        }<br />
        <br />
    }</p>

    Tags:IBM TCS

    Question :: 2
    Write code for swapping two variables without using 3rd variable.

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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();
    }
    Question :: 3
    Write a program to print prime numbers upto 10.

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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();
    }
    Question :: 4
    Write a program to print the nth fibonacci number.

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Experience
    Answer In: C  
     
    <p>#include<stdio.h><br />
    #include<stdlib.h><br />
    int main(int varc,char *varg[])<br />
    {<br />
     int n=atoi(varg[1]);<br />
     int n1=0,n2=1,n3,i,sum;<br />
     if(a==1)<br />
     printf("%d",0);<br />
     if(a==2)<br />
     printf("%d",1);<br />
     if(a>2)<br />
     {<br />
      for(i=3;i<=n;i  )<br />
      {<br />
       n3=n2 n1;<br />
       n1=n2;<br />
       n2=n3;<br />
       printf("%d  ",n3);<br />
      }<br />
     }<br />
     return 0;<br />
    }</p>
    Question :: 5
    Write a program to print odd number in descending order from 1-10.

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    Answer In: C  
     
    <p>#include<stdio.h><br />
    #include<conio.h><br />
    void main()<br />
    {<br />
        int i,j=2;<br />
        for(i=10;i>=1;i--)<br />
        {<br />
            if(i%j==1)<br />
            {<br />
                printf("%d",i);<br />
            }<br />
        }<br />
    }</p>

    Tags:TCS

    Question :: 6
    Write a Program to generate random numbers.

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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

    Question :: 7
    Write a program using command line argument to input a word and check whether it is palindrome or not.

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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

    Question :: 8
    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 : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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

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

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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

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

    Input : NA


    Output : NA

    View Answer View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Tag to companies Asked In |  Fresher
    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