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



    51 / 348

    Write a program to enter a sentence then find 2 last word of sentence

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include <iostream>
    using namespace std;
    string getLastWord(string text)
    {
        string lastword="";
        int last=text.size()- 1;
        int beginlast=0;
        if text == "";
        return  "";
        for (int i=last; i>=1; i--)
        {
            if (isspace(text[i]))
                beginlast=beginlast+i;
        }
        for (int k=0; k!=text.size; k++)
        {
            if (isalpha(text[k]))
                lastword=lastword+lastword[k];
        }
        return lastword;
    }
    int main()
    { char str[20];
    cout<<"enter string";
    cin>>str;
    getLastWord(str);
    return 0;
    }

    Tags:IBM

    52 / 348

    Write a program to enter a string then convert the string into reverse order.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include<iostream.h>
    
    #include<conio.h>
    #include<stdio.h>
    void main()
    {
        clrscr();
        char str[100], temp;
        int i=0, j;
        cout<<"Enter the String : ";
        gets(str);
        i=0;
        j=strlen(str)-1;
        while(i<j)
        {
            temp=str[i];
            str[i]=str[j];
            str[j]=temp;
            i++;
            j--;
        }
        cout<<"Reverse of the String = "<<str;
        getch();
    }

    Tags:IBM PEOL

    53 / 348

    Write a program to enter the string then find the respective ascii value of the string.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    int myAtoi(char *str)
    {
        int res = 0; /*Initialize result*/  
        /* Iterate through all characters of input string and update result*/
        for (int i = 0; str[i] != '\0'; ++i)
            res = res*10 + str[i] - '0';  
        /* return result.*/
        return res;
    }
    /*Driver program to test above function*/
    int main()
    {
        char str[] = "89789";
        int val = myAtoi(str);
      cout<< val;
        return 0;
    }

    Tags:IBM

    54 / 348

    Write a program to enter the string then count the length of the string.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include <iostream>
    
    using namespace std;
    int main()
    {
        string str = "C++ Programming";

        /* you can also use str.length()*/
        cout << "String Length = " << str.size();

        return 0;
    }

    Tags:IBM

    55 / 348

    Write a program to enter the sentence then find the word from the sentence.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: JAVA   PHP  
     
    <!DOCTYPE html>
    <html>
    <body>

    <?php 
    function String_word() {
        
    $str ="what is your name"/* input string */
        
    echo  "Input string is :" $str."<br/>";
        
    $arr explode" "$str); /* conversion of string into array */
        
    $arrlength=count ($arr);  /* counting lengh of array */
        
    $word="your";  /* initialising an empty array and its initial index */
        
    for( $x =0;$x<=$arrlength$x++) /* loop for reading the input array */
        
    {
            if(
    $arr[$x]==$word)
            {    
    $pos=$x;
                break;
            }
        }
       echo 
    $word."- word found at position:  ".++$pos;                                                                        // printing string in reverse order
    }
     
    String_word();
    ?>

    </body>
    </html>

    Tags:IBM

    56 / 348

    Write a program to enter a string then count the no. of vowels in the string.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include <iostream>
    using namespace std;
    int main()
    {
        char line[150];
        int vowels, consonants;
        vowels =  consonants = 0;
        cout << "Enter a line of string: ";
        cin.getline(line, 150);
        for(int i = 0; line[i]!='\0'; ++i)
        {
            if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
               line[i]=='o' || line[i]=='u' || line[i]=='A' ||
               line[i]=='E' || line[i]=='I' || line[i]=='O' ||
               line[i]=='U')
            {
                ++vowels;
            }
            else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
            {
                ++consonants;
            }        
        }
        cout << "Vowels: " << vowels << endl;
        cout << "Consonants: " << consonants << endl;
        return 0;
    }

    Tags:IBM

    57 / 348

    Write a program to enter a string then print the longest String in java string array.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA  
     
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    #include <iostream>
    using namespace std; 
    {
        char string[100], word[20], max[20], min[20], c;
        int i = 0, j = 0, flag = 0;
     
      cout<<"Enter string: ";
        i = 0;
        do
        {
            fflush(stdin);
            c = getchar();
            string[i++] = c; 
        } while (c != '\n');
        string[i - 1] = '\0';
        for (i = 0; i < strlen(string); i++)
        {
            while (i < strlen(string) && !isspace(string[i]) && isalnum(string[i]))
            {
                word[j++] = string[i++];
            }
            if (j != 0)
            {
                word[j] = '\0';
                if (!flag)
                {
                    flag = !flag;
                    strcpy(max, word);
                    strcpy(min, word);
                }
                if (strlen(word) > strlen(max))
                {
                    strcpy(max, word);
                }
                if (strlen(word) < strlen(min))
                {
                    strcpy(min, word);
                }
                j = 0;
            }
        }
        cout<<"The largest word is '%s' and smallest word is '%s' in '%s'.\n", max, min, string;
        return 0;
    }

    Tags:IBM

    58 / 348

    Write a program to print a desired character from string

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    using namespace std;
    void main()
    {
        int i, j, k, count = 0;
        char str[50]; 
       cout<<"enter string\n";
        cin>>str;
        k = strlen(str);
        cout<<"desired characters in a string is\n";
        for (i = 2;i <= k;i++)
        {    
              cout<<str[i - 1];
        }
    }

    Tags:IBM

    59 / 348

    Write a program to enter the string then delete the vowels from string.

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    using namespace std;
    int check_vowel(char);
    int main()
    {
      char s[100], t[100];
      int i, j = 0; 
    cout<<"Enter a string to delete vowels\n";
      gets(s);
      for(i = 0; s[i] != '\0'; i++) {
        if(check_vowel(s[i]) == 0) {       //not a vowel
          t[j] = s[i];
          j++;
        }
      }
      t[j] = '\0';
      strcpy(s, t);    //We are changing initial string
     cout<<"String after deleting vowels: %s\n";
      return 0;
    }
    int check_vowel(char c)
    {
      switch(c) {
        case 'a':
        case 'A':
        case 'e':
        case 'E':
        case 'i':
        case 'I':
        case 'o':
        case 'O':
        case 'u':
        case 'U':
          return 1;
        default:
          return 0;
      }
    }

    Tags:IBM

    60 / 348

    Write fibonacci series program. INPUT: 10 term OUTPUT: 0 1 1 2 3 5 8 13 21 34

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP  
     
    #include <iostream>
    using namespace std;
    int main()
    {
        int n, t1 = 0, t2 = 1, nextTerm = 0;
        cout << "Enter the number of terms: ";
        cin >> n;
        cout << "Fibonacci Series: ";
        for (int i = 1; i <= n; ++i)
        {
            /* Prints the first two terms*/
            if(i == 1)
            {
                cout << " " << t1;
                continue;
            }
            if(i == 2)
            {
                cout << t2 << " ";
                continue;
            }
            nextTerm = t1 + t2;
            t1 = t2;
            t2 = nextTerm;      
            cout << nextTerm << " ";
        }
        return 0;
    }