Recommended For You

Monday, August 24, 2020

Pseudo Codes 3- Based On Format Specifiers and Variables Decleration

   



                                    

                     

















1. 
#include <stdio.h>
int main()
{
    char ch = 'A';
    printf("%d\n", ch);
    return 0;
}


  1. A
  2. 'A'
  3. 65
  4. 97
Ans- 3

2.
Which of the following is not a valid declaration in C ?

1.short int x;

2.signed short x;

3.short x;

4.unsigned short x;



  1. 3 and 4
  2. 1
  3. 2
  4. All are valid
Ans- 4



3.

#include <stdio.h>
int i;
int main()
{
    if (i)
        ;
    else
        printf("Ëlse");
    return 0;
}


  1. if block is executed.
  2. else block is executed
  3. It is unpredictable as i is not initialized.
  4. Error: misplaced else
Ans- 2

4.
void swap(int x, int y)
{
    int tmp;
    tmp = x;
    x = y;
    y = tmp;
}



  1. Call swap (a, b)
  2. Call swap (&a, &b)
  3. swap(a, b) cannot be used as it does not return any value
  4. swap(a, b) cannot be used as the parameters passed by value
Ans- 4


5.
What will be the output of the following code snippet?


#include <stdio.h>
int foo(int* a, int* b)
{
    int sum = *+ *b;
    *= *a;
    return *= sum - *b;
}
int main()
{
    int i = 0, j = 1, k = 2, l;
    l = i++ || foo(&j, &k);
    printf("%d %d %d %d", i, j, k, l);
    return 0;
}



  1. 1 2 1 1
  2. 1 1 2 1
  3. 1 2 2 1
  4. 1 2 2 2
Ans- 1

No comments:

Post a Comment