Class 9 INTRODUCTION TO C PROGRAMING CHAPTER 8 (1).web

      Chapter - 8
      INTRODUCTION TO C PROGGRAMING

      1. Fill int the blanks:

      a. C is the only high- level programing language (True/False)   False.

      b. IDE stand for  Integrated Development Kit.

      c. We always need a very powerful computer to run C program (True/False) False.

      d. Every statement in a C program has to end with a semicolon(;).

      e. Execution of a program start from main() function.

       

      2. Short answer questions( Answer should preferably be of 2-3 lines);

      a. While writing a computer program, what does a programmer need to assume about the cpu and the storage.

      Ans: While witting a computer program, we assume that we have a computation or processing element (i.e. the CPU0 and a huge memory where data will be stored. This is also called the programmer’s view of memory.

      b. Do we always need Codeblock to write C programs? Explain.

      Ans: No, we can write C program in any IDE which support program. There are many IDE where we can do C program. Some of them are VS code, Turbo C++, Dev C etc.

      c. Why do we need header files? Name a few standard header files in C.

      Ans: The header files contains definitions of many functions (such as printf(), scanf(), etc.) that we use in our program. A few header file in C are stdio.h, conio.h, math.h, stdlib.h etc.

       

      3. Long answer questions (Answer should preferably be of 5-6 lines):

      a. Explain the process of compilation of a C program with the name Namaskar.c, what files will be created at each step of compilation?

      Ans: As we have done our program using IDE, we do not care much about these steps. But many interesting things happen inside. They are:

      In the preprocessor step, the compiler removes the comment lines from the program. If the source file name is Prog1.C, then this step produce output as Prog,1.i.

      In the next step, the expanded file is compiled and converted into assembly language as Prog1.s. Then the generated assembly language code prog1.s is converted into machine language code Prog1.o.

      The last step of the compilation is linking. Then the compiler generate the executable code as Prog1.exe

      b.  Can we compile an erroneous code in C? if we do not write the function main () in our C program, will it compile successfully?

      Ans: No, we must correct the errors befoe compiling a C program. The execution of any program start from special function main(). All C programs must have this function. So if we do not write function main() in our C program, it will not compile.

       

      c. What is a programmer’s view of memory? Is it different from actual memory? Explain briefly.

      Ans: When we code, we play the role of a programmer rather than a user. While writing a computer program, we assume that we have a computation or processing element (i.e., the CPU) and a huge memory, where data will be stored. This is also called the programmer’s view of memory. It is different from actual memory.


      4. Programing Assignments:

      a. Write and execute a program to print your name.

      Ans: Program to print my name

      #include <sdio.h>

      int main()

      {

      printf(“Here type Your Name”);

      return 0;

      }

       

       

      b. write and execute a c program to print your name and your mother name in two different lines but using single printf.

      Ans:

      #include <sdio.h>

      int main()

      {

      printf(“Your Name and \n Your Mother’s Name”);

      return 0;

      }

       

      c. Write and execute a C program to print the sentence “ I am from Assam. I am a responsible citizen of my country”. Five times.

      Ans:

      #include <sdio.h>

      int main()

      {

      printf(“I am from Assam. I am a responsible citizen of my country\n”);

      printf(“I am from Assam. I am a responsible citizen of my country\n”);

      printf(“I am from Assam. I am a responsible citizen of my country\n”);

      printf(“I am from Assam. I am a responsible citizen of my country\n”);

      printf(“I am from Assam. I am a responsible citizen of my country\n”);

       

      return 0;

      }

       

       

      d. Remove the semicolon(;) from the C program of the previous question. Compile the program and check the errors. Note the line numbers and then rectify them.

       

      e. write and execute a C program to print your name in the order last name first name. but you will pass them in first name last name order inside printf [Hint: use proper escape sequence]

      Ans:

      #include <sdio.h>

      int main()

      {

      printf(“Saint \r Joseph’s”);

       

      return 0;

      }

       

      Table of Content