C Programming Que. paper.

gaurav.bhorkar

gaurav.bhorkar

@gauravbhorkar-Pf9kZD Oct 22, 2024
I want to share some of the questions from my 3rd sem exam of C language.
Sharing ALL questions is not possible. (Most of them are easy)

Q1. Distinguish between (*m)[5] and *m[5]?

Q2. What is UNION? How it is different from STRUCTURE?

Q3. Distinguish between syntax and semantic error?

Q4. What do you mean by Input/Output stream?

Q5. Find the output of the program:
main()
{
int a=10, b=20, c=30, d;
d = a > b ? (a > c ? a : c) : b > c ? b : c;
printf ("%d",d);
}


Very easy questions!:smile:

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • yadavundertaker mohit

    yadavundertaker mohit

    @yadavundertaker-0p3HBs Nov 10, 2009

    for you they seems to be easy but for me like Schrödinger equation
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Nov 10, 2009

    5😲utput of program will be 30
  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Nov 10, 2009

    if you know Structure you also know Union

    they are collection of various data types but have a difference

    The memory of Structure is equal to the sum of the memory of all the data types

    But Union takes only the largest value only

    Say we have a char, int then memory for structure will be 3 while Union it will be 2
  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Nov 10, 2009

    Syntax error is the error in the syntax that is use forget to follow the rules of writing code in C

    it means you forget a ';' or make a spelling mistake of 'printf to be pintf'

    Semantics are the logical errors they are generally not recognised by the compiler with exceptions of divide by zero

    Semantics means you have done a+b when you had to do a+c
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Nov 10, 2009

    goyal420
    5😲utput of program will be 30
    Can you give justification for your answer?
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Nov 10, 2009

    @sarveshgupta
    All your answers are correct. Good.
  • Maelstrom

    Maelstrom

    @maelstrom-jwDZvD Nov 10, 2009

    gaurav.bhorkar
    Q1. Distinguish between (*m)[5] and *m[5]?
    (*m)[5] means "pointer to an array of 5 integers"
    *m[5] means "array of integer pointers"

    As for the Input/Output stream question, I'm not sure, but I think that they are interfaces provided to the programmer to ensure that he does not have to worry about the actual implementation of input/output (i.e. writing individual bytes to printer or monitor etc.).
  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Nov 11, 2009

    Thanks Gaurav

    And as far as input/output stream are concerned

    Stream is an array of bytes

    all the input output of the values is considered as a stream of bytes by the compiler

    an int variable has 2 bytes , a char has 1 byte

    When the input and output is performed it is considered as bytes
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Nov 11, 2009

    main()
    {
    int a=10, b=20, c=30, d;
    d = a > b ? (a > c ? a : c) : b > c ? b : c;
    printf ("%d",d);
    }
    first of all it will check whether a>b ie not true so it check b>c which is again false
    so it will give value 30
    I hope my answer is not wrong
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Nov 11, 2009

    goyal420
    main()
    {
    int a=10, b=20, c=30, d;
    d = a > b ? (a > c ? a : c) : b > c ? b : c;
    printf ("%d",d);

    }
    first of all it will check whether a>b ie not true so it check b>c which is again false
    so it will give value 30
    I hope my answer is not wrong
    You are absolutely correct. Good Job!
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Nov 11, 2009

    I don't know about Input/Output stream.

    Sarveshgupta may be correct.
  • Gurjeet Singh

    Gurjeet Singh

    @gurjeet-LUX7B1 Nov 11, 2009

    main()
    {
    printf("%%%%%",7);
    }
    what is the output:
    1:7
    2:error
    3:%%%
    4:%%%%%
  • Saandeep Sreerambatla

    Saandeep Sreerambatla

    @saandeep-sreerambatla-hWHU1M Nov 11, 2009

    It gives syntax error 😀

    The bracket mustbe } not {

    PS.Start new thread for questions 😀
  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Nov 11, 2009

    I think he has placed that bracket by mistake

    and printf has everything inside double quotes except the variables whose values are to be substituted with their type specifiers
    Hope i am correct