C Programming Que. paper.

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

  • yadavundertaker mohit
    yadavundertaker mohit
    for you they seems to be easy but for me like Schrödinger equation
  • Manish Goyal
    Manish Goyal
    5😲utput of program will be 30
  • sarveshgupta
    sarveshgupta
    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
    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
    goyal420
    5😲utput of program will be 30
    Can you give justification for your answer?
  • gaurav.bhorkar
    gaurav.bhorkar
    @sarveshgupta
    All your answers are correct. Good.
  • Maelstrom
    Maelstrom
    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
    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
    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
    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
    I don't know about Input/Output stream.

    Sarveshgupta may be correct.
  • Gurjeet Singh
    Gurjeet Singh
    main()
    {
    printf("%%%%%",7);
    }
    what is the output:
    1:7
    2:error
    3:%%%
    4:%%%%%
  • Saandeep Sreerambatla
    Saandeep Sreerambatla
    It gives syntax error 😀

    The bracket mustbe } not {

    PS.Start new thread for questions 😀
  • sarveshgupta
    sarveshgupta
    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

You are reading an archived discussion.

Related Posts

I have passed B.E (ICE) in anna univ. Im planning to do my M.S. (Research) for which Im looking for research topic. I prefer to do in one of the...
This is somewhat shocking to me. JAM (Just Another Magazine) magazine has reported that the credentials of IIM Shillong's director are questionable. The magazine reports: No less than 7 of...
well, I have project for my grade 12 board exam in subject Informatics Practices. I have to make a inventory system and have to produce reports . For this I...
I have created a login form for connecting vb6 to oracle .The following code I have wrote in click event of button login. Private Sub cmdlogin_Click() Dim con As New...
If you're looking to monitor your network and Internet speed, track overall bandwidth usage, and get several other very useful utilities, you'd do well to download the free NetWorx. With...