Technical Questions asked in Adobe

  1. Write a program to calculate factorial of a number
    Answer:
    #include
    #include
    int main()
    {int i,num,fact=1;
    cout<<”\nenter integer:”;
    cin>> num;
    i=num;
    while(num>0)
    {
    fact= fact*num;
    --num;
    }
    cout<< fact;
    return 0;
    }
  2. Given the following for loop :
    const int Z=25;
    for(int i=0,sum=0;i sum +=i;}
    cout<< sum;
    Write equivalent while loop for above code

    Answer:
    const int Z= 25;
    int i=0, sum=0;
    while i
    {
    sum+=I;
    i++;
    }
    cout<< sum;
  3. Write a C++ program to check whether the given number is palindrome or not
    Answer:
    #include
    int main()
    {
    int n, num, digit,rev=0;
    cout<< “Input the number(max 32767) :” ;
    cin>> num ;
    n=num;
    do
    {
    digit= num%10;
    rev = (rev*10) + digit ;
    num= num/10;
    }
    while(num!= 0);
    cout<< rev ;
    if(n== rev)
    cout<< “ The number is palindrome” ;
    else
    cout<< “ The number is not a palindrome “;
    return 0;
    }
  4. Write a C++ program to print fibonacci series i.e. 0 1 1 2 3 5 8
    Answer:
    #include
    Int main()
    {unsigned long first , seconf, third,n;
    first= 0;
    second= 1;
    cout<< “how many element (>5)?” ;
    cin>> n;
    cout<< “fibonacci series”;
    cout<< first << “ “<< second ;
    for (int i=2;i {
    third = first + second ;
    cout<< “” << third;
    first= second;
    second= third ;
    }
    return 0 ;
    }
  5. Write a program to swap two values
    Answer:
    #include
    int main()
    {
    void swap(int&, int&);
    int a,b;
    a=7;
    b=4;
    cout << “a=”<< a << “b=” << b<< “\n”;
    swap(a,b);
    cout << “a=”<< a << “b=” << b;
    return 0;
    }
    void swap(int &x, int &y)
    {
    int temp ;
    temp = x;
    x=y;
    y= temp ;
    }
  6. Write a C++ program that checks whether the given character is alphanumeric or a digit.Add appropriate header file.
    Answer:
    #include
    #include
    int main()
    {
    char ch;
    int a ;
    cout<< “ Enter character”;
    cin>> ch;
    a=ch;
    if(isalnum(a))
    {
    cout<< “Alphanumeric Character” ;
    if( isdigit(a))
    cout<< “And digit charcter” ;
    else if(isalpha(a))
    cout<< “And Alphabetic charcter”;
    }
    else
    cout<,”other character”;
    return 0;
    }
Test Site