Skip to main content

Posts

Tricky Question in C

Q. What will be output if you execute the following c code? void   main (){    int  i=10;    static   int  value=i;    if (value==i)       printf( "Both are Equal" );    else   if (x>i)       printf( "value is Greater than i" );    else       printf( "value is Less than i" ); } (a)  Both are Equal (b)  value is Greater than i (c)  value is Less than i (d) Compiler error (e) None of above Ans:   (d) Explanation: As we know that static variables are load time entity while auto variables are run time entity. Son it is not possible to initialize any load time variable by the run time variable. In the above example i is a run time variable while x is load time variable.

C program on Android phone

Q. How to run any C program on your Android Phone? It is possible to run any C program on your Android Smart Phone. Please follow the following steps to run C program on your phone. Steps  : 1. At first press menu button in your Android phone then select Play store . 2. Now type CppDroid on search box and then press ok. 3. After that install CppDroid app from play store. ( your phone is ready to run any C program on your Android   Phone. ) 4. Now close play store and again press menu button. 5. Select CppDroid from the menu window( first time it will download some of the file after opening this app ) now write any    C program to run on your phone.

Algorithm, Flowchart and Program code to print the larger of two numbers

       Q. Write a program in C to print the larger of two numbers with                t he  help of   algorithm and flowchart.        Algorithm:        Step 1: Start       Step 2: Read a, b .        /* a, b two numbers */        Step 3: If a>b then        /*Checking */                       Display “a is the largest number”.                   Otherwise                       Display “b is the largest number”.   Step 4: Stop.     Flowchart  :     Program:       Output: