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



    91 / 348

    Write a recursive function to find the length of the of 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++  
     
    #include <stdio.h>
    #include <iostream>
    using namespace std; 
    int stringLength(char *str)
    {
        static int length=0;
        if(*str!=NULL)
        {
            length++;
            stringLength(++str);
        }
        else
        {
            return length;
        }
    }
    int main()
    {
        char str[100];
        int length=0;    
        cout<<"Enter a string: ";
        gets(str);
        length=stringLength(str);
        cout<<"Total number of characters (string length) are:\n"<<length;
        return 0;
    }

    Tags:PEOL

    92 / 348

    Write a program to remove the blank space from the string without using built in function

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C   C++  
     
    #include <stdio.h>
    
     #include <iostream>
    using namespace std;
    int main()
    {
       char text[1000], blank[1000];
       int c = 0, d = 0;
       cout<<"Enter some text\n";
       gets(text);
       while (text[c] != '\0') {
          if (text[c] == ' ') {
             int temp = c + 1;
             if (text[temp] != '\0') {
                while (text[temp] == ' ' && text[temp] != '\0') {
                   if (text[temp] == ' ') {
                      c++;
                   }  
                   temp++;
                }
             }
          }
          blank[d] = text[c];
          c++;
          d++;
       }
       blank[d] = '\0';
        cout<<"Text after removing blanks\n%s\n"<<blank;
       return 0;
    }

    Tags:PEOL

    93 / 348

    Write code to remove comment lines.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C   C++  
     
    #include <iostream>
    using namespace std;
    string removeComments(string prgm)
    {
        int n = prgm.length();
        string res;
        /* Flags to indicate that single line and multpile line comments */
        /* have started or not */
        bool s_cmt = false;
        bool m_cmt = false;
        /* Traverse the given program */
        for (int i=0; i<n; i++)
        {
            /* If single line comment flag is on, then check for end of it*/
            if (s_cmt == true && prgm[i] == '\n')
                s_cmt = false;
            /* If multiple line comment is on, then check for end of it*/
            else if (m_cmt == true && prgm[i] == '*' && prgm[i+1] == '/')
                m_cmt = false, i++;
            /* If this character is in a comment, ignore it*/
            else if (s_cmt || m_cmt)
                continue;
            /* Check for beginning of comments and set the approproate flags*/
            else if (prgm[i] == '/' && prgm[i+1] == '/')
                s_cmt = true, i++;
            else if (prgm[i] == '/' && prgm[i+1] == '*')
                m_cmt = true, i++;

            /* If current character is a non-comment character, append it to res*/
            else res += prgm[i];
        }
        return res;
    }

    /* Driver program to test above functions*/
    int main()
    {
        string prgm = " /* Test program */ \n"
                    " int main() \n"
                    " {         \n"
                    "     // variable declaration \n"
                    "     int a, b, c; \n"
                    "     /* This is a test \n"
                    "         multiline     \n"
                    "         comment for \n"
                    "         testing */     \n"
                    "     a = b + c;     \n"
                    " }         \n";
        cout << "Given Program \n";
        cout << prgm << endl;
        cout << " Modified Program ";
        cout << removeComments(prgm);
        return 0;
    }

    Tags:PEOL

    94 / 348

    Write a program to find the sum of digits in number.

    Input : 243


    Output : 2+4+3=9

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA  
     
    #include<iostream>
    
    using namespace std;
    int main()
    {
        int val, num, sum = 0;
        cout << "Enter the number : ";
        cin >> val;
        num = val;
        while (num != 0)
        {
            sum = sum + num % 10;
            num = num / 10;
        }
        cout << "The sum of the digits of "
             << val << " is " << sum;
    }

    Tags:PEOL

    95 / 348

    Write a program to reverse the string using linked list

    Input : NA


    Output : NA

    View Answer |  Linked List |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++  
     
    #include "stdio.h"
    #include "string.h"                        
    #include "malloc.h"
    #include<iostream>
    using namespace std;
    typedef struct Rev{
     char a;
     struct Rev *link;
    }Rev;
    int main(){
     Rev *head=NULL,*temp=NULL,*temp1=NULL,*temp2=NULL;
     char b[20];
     int i,j=0,len;
     cout<<"Enter a String: ";
     gets(b);
     len=strlen(b);
     for(i=0;i
      if(head==NULL){
       head=(Rev *)malloc(sizeof(Rev));
       head->a=b[i];
       head->link=NULL;
      }
      else
      {
       temp=head;
       while(temp->link != NULL){
        temp=temp->link;
       }
       temp->link=(Rev *)malloc(sizeof(Rev));
       temp->link->link=NULL;
       temp->link->a=b[i];
      }

     }
     for(i=0;i
      temp1=head;
      temp2=temp1->link;
      if(temp2 != NULL){
      while(temp2->link != NULL){
       temp2=temp2->link;
       temp1=temp1->link;
      }
     cout<<temp2->a;
      temp1->link=NULL;
      }
      else
      {
       cout<<temp1->a;
      }
     }
     return 0;
    }

    Tags:PEOL

    96 / 348

    Write program for 2^n.

    Input : n=42^4=


    Output : 2^4=16

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C   C++   JAVA  
     
    #include <iostream>
    #include <iomanip> 
    union doubleUnion{
        double d;
        uint64_t i;
    };
    int main() {
        doubleUnion num;
        const uint64_t expbit = uint64_t(1)<<52;
        num.d = 1;
        for(int i = 0; i < (1<<10); i++){
            std::cout << std::fixed << std::setprecision(0) << num.d << std::endl;
            num.i += expbit;
        }   
    }

    Tags:PEOL

    97 / 348

    Write program to find out second larges number in given number.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C   C++   JAVA  
     
    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int main() {
        int a[10], n;
        int largest1, largest2, i;

        cout<<"enter number of elements you want in array";
        cin>>n;
         cout<<"enter elements";
        for (i = 0; i < n; i++) {
           cin>>a[i];
        }
        largest1 = a[0];
        for (i = 0; i < n; i++) {
            if (a[i] > largest1) {
                largest1 = a[i];
            }
        }
        largest2 = a[0];
        for (i = 1; i < n; i++) {
            if (a[i] > largest2 && a[i] < largest1)
                largest2 = a[i];
        }
         cout<<"First and second largest number is "<< largest1<<"and"<<largest2;
    }

    Tags:PEOL

    98 / 348

    Write a program to find the difference of two numbers must always be positive.

    Input : Input 1: 10 15 Input 2: 45 40 Input 3: 20 34


    Output : output 1: 5 output 2: 5 output 3: 14

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience
    Answer In: C   C++  
     
    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int main() {
        int a[10], n;
        int largest1, largest2, i;

        cout<<"enter number of elements you want in array";
        cin>>n;
         cout<<"enter elements";
        for (i = 0; i < n; i++) {
           cin>>a[i];
        }
        largest1 = a[0];
        for (i = 0; i < n; i++) {
            if (a[i] > largest1) {
                largest1 = a[i];
            }
        }
        largest2 = a[0];
        for (i = 1; i < n; i++) {
            if (a[i] > largest2 && a[i] < largest1)
                largest2 = a[i];
        }
         cout<<"First and second largest number is "<< largest1<<"and"<<largest2;
    }

    99 / 348

    Write a recursive function to find the length of the of string

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience
    Answer In: C   C++  
     
    #include <stdio.h>
    #include <iostream>
    using namespace std; 
    int stringLength(char *str)
    {
        static int length=0;
        if(*str!=NULL)
        {
            length++;
            stringLength(++str);
        }
        else
        {
            return length;
        }
    }
    int main()
    {
        char str[100];
        int length=0;   
        cout<<"Enter a string: ";
        gets(str);
        length=stringLength(str);
        cout<<"Total number of characters (string length) are:\n"<<length;
        return 0;
    }

    Tags:No Tags on this question yet!

    100 / 348

    Write a program to convert Fahrenheit to centigrade and test that program and tell an exact value to test all most all scenario.

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience
    Answer In: C   C++  
     
    #include<stdio.h>
    #include<conio.h>
    #include<iostream>
    using namespace std;
    void main()
    {
        clrscr();
        float fah, cel;
        cout<<"Enter temperature in Fahrenheit : ";
        cin>>fah;
        cel=(fah-32) / 1.8;
        cout<<"Temperature in Celsius = "<<cel;
        getch();
    }

    Tags:Adobe