Thursday, 21 September 2017

Basic Programming questions of C Language:


C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.
The C Language is developed for creating system applications that directly interact with the hardware devices such as drivers, kernels etc.
C programming is considered as the base for other programming languages, that is why it is known as mother language.

It can be defined by following ways:

  1. Mother language
  2. System programming language
  3. Procedure-oriented programming language
  4. Structured programming language
  5. Mid-level programming language

 1    #include <stdio.h>
        void main()
        {
            int x = 1, y = 0, z = 5;
            int a = x && y || z++;
            printf("%d", z);
        }


Please check your answer here: jdoodle.com/a/75D


2    #include <stdio.h>
        void main()
        {
            int x = 1, y = 0, z = 5;
            int a = x && y && z++;
            printf("%d", z);
        }


Please check your answer here: jdoodle.com/a/75F


 3   #include <stdio.h>
       int main()
        {
            int x = 1, y = 0, z = 3;
            x > y ? printf("%d", z) : return z;
        } 


Please check your answer here: jdoodle.com/a/75J


4   #include <stdio.h>
      void main()
        {
            int x = 1, z = 3;
            int y = x << 3;
            printf(" %d\n", y);
        }


Please check your answer here: jdoodle.com/a/75N


5    #include <stdio.h>
       void main()
        {
            int x = 0, y = 2, z = 3;
            int a = x & y | z;
            printf("%d", a);
        }


Please check your answer here: jdoodle.com/a/75O

 
 6   #include <stdio.h>
        int main()
        {
            int i = 1;
            if (i++ && (i == 1))
                printf("Yes\n");
            else
                printf("No\n");
        }


 Please check your answer here: jdoodle.com/a/75P


  7    #include <stdio.h>
int main()
        {
            int x = 2, y = 0;
            int z = (y++) ? y == 1 && x : 0;
            printf("%d\n", z);
            return 0;
        }


Please check your answer here:  jdoodle.com/a/75x

 8   #include <stdio.h>
        int main()
        {
            int x = 1;
            int y =  x == 1 ? getchar(): 2;
            printf("%d\n", y);
        }


Please check your answer here: jdoodle.com/a/75R


  9   #include <stdio.h>


        int main()


        {
            int x = 1;


            short int i = 2;


            float f = 3;


            if (sizeof((x == 2) ? f : i) == sizeof(float))


                printf("float\n");


            else if (sizeof((x == 2) ? f : i) == sizeof(short int))


                printf("short int\n");
        }


Please check your answer here:  jdoodle.com/a/75x

 10  #include <stdio.h>
        int main()
        {
            int a = 2;
            int b = 0;
            int y = (b == 0) ? a :(a > b) ? (b = 1): a;
            printf("%d\n", y);
        }

  
Please check your answer here: jdoodle.com/a/75S







Thanks

Mukesh Rajput

No comments:

Post a Comment

Thanks
Mukesh Rajput