.
  Vyom World.com . Let's Touch the Sky Together!  
.

Home
VyomWorld.com Home
Interview Questions
VyomLinks.com Home
JobsAssist.com Home
Vyom Network
Contact Us
Jobs & Careers
Resume Submitter
Placement Papers
IT Companies Directory
Computer Jobs
Interview Questions
Online Exams
Vyom Career eMag.
Fun
Send FREE SMS!
SMS Jokes
Source Codes Library
Source Codes Home
ASP Source Codes
C Source Codes
C++ Source Codes
COBOL Source Codes
Java Source Codes
Pascal Source Codes
Submit Source Codes
GATE
GATE an Overview
GATE Preparation
Study Materal
GRE
GRE an Overview
GRE Questions
GRE Preparation
GRE Universities
TOEFL Preparation
TOEFL Resources
GMAT Preparation
GMAT Resources
MBA Preparation
MBA Resources
Networking Concepts
Networking Concepts
Testing Preparation
Testing Resources
Webmasters
Free Traffic Builder
Webmaster Articles
Web Hosting
Tutorials
Hardware Tutorial
1500 Free eBooks New!


Home » Placement Papers » Sapient Placement Papers » Sapient Previous Year Placement Paper

 

Sapient Placement Paper -: Programming Questions With Answers


Advertisements
Advertisements




Sapient Previous Years Solved Sample Placement Papers

  1. What will be the output of the following C program?
    void main()
    {
    int a[] = {5, 10, 15};
    int i = 0, num;
    num = a[++i] + ++i + (++i);
    printf("%d", num);
    }

    A. 6 Answer: A

    B. 17

    C. 16

    D. 12

    Solution: The `++i` modifies the index before accessing the array. Calculations proceed as: a[1] + 2 + 3 = 6.

  2. What will be the output of the program?
    #include
    int main()
    {
    int i = 5;
    while (i-- >= 0)
    printf("%d,", i);
    i = 5;
    printf("n");
    while (i-- >= 0)
    printf("%i,", i);
    while (i-- >= 0)
    printf("%d,", i);
    return 0;
    }

    A. 4, 3, 2, 1, 0, -1
    4, 3, 2, 1, 0, -1 Answer: A

    B. 5, 4, 3, 2, 1, 0
    5, 4, 3, 2, 1, 0

    C. Error

    D. 5, 4, 3, 2, 1, 0
    5, 4, 3, 2, 1, 0
    5, 4, 3, 2, 1, 0

    Solution: The `--` operator decrements `i` during the checks, leading to two identical decrements for the first two loops.

  3. Point out the error in the following program:
    #include
    int main()
    {
    char str[] = "Freshersworld";
    printf("%.#s %2s", str, str);
    return 0;
    }

    A. In array declaration

    B. printf statement

    C. Unspecified character in printf

    D. No error Answer: D

    Solution: The syntax may seem unusual, but it will compile and run successfully without any issues.

  4. Find the output of the following snippet:
    #include
    void main()
    {
    char letter = 'Z';
    printf("%c", letter);
    }

    A. Z Answer: A

    B. 90

    C. Garbage Value

    D. Error

    Solution: The character `Z` is printed directly as it is assigned to the variable.

  5. What will be the output of the program?
    #include
    #define SQR(x) (x * x)
    int main()
    {
    int a, b = 3;
    a = SQR(b + 2);
    printf("%d", a);
    return 0;
    }

    A. 25

    B. 11 Answer: B

    C. Error

    D. Garbage Value

    Solution: The macro replacement happens without parentheses around the expression. So, SQR(b+2) becomes b + 2 * b + 2 = 3 + 6 + 2 = 11.

  6. What will be the output of the program if value 25 is given to scanf()?
    #include
    int main()
    {
    int i;
    printf("%d", scanf("%d", &i));
    return 0;
    }

    A. 1 Answer: A

    B. 2

    C. 5

    D. 25

    Solution: The `scanf` function returns the number of successful input variables. Here, only one value (25) is read successfully, so the return value is `1`.




 


.

Recently Updated: New Placement Papers added.
Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Programming & Source Codes | GRE Preparation | Jobs, Discussions | Software Listing | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | International Business Information | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | FAQs | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Excellent Mobiles | Software Testing | Interview Questions | Freshers Jobs | Server Insiders | File Extension Directory

Copyright ©2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved. Read our Privacy Policy