Posts

Showing posts with the label Computer Science

Programming in C, Variables, Numeric Variable, Character Variable.

Image
Question 1: Describe the purpose of variables. Ans:   A variable is a symbolic name that represents a value  that can change during execution of a program. A variable  has a name, known as variable name and it hold data of  other types. These are called memory  locations. Variables are of two types. 1.  Numeric Variable 2.  Character Variable Variables Question 2: What is the difference between  numeric and character  variable? Ans:   Numeric variables  are used to represent numeric values in computer programs. e.g: sum, avg, marks, etc Character variables  represent character values in computer program. It can represent a single character or a string of characters. e.g: city, gender etc.

Programming In C, main() function, global and local variables, Comments in C Language

Image
Question 1.  Describe the purpose of the  main () function and the body  of  main() function Ans:   Every C program must  have the function main() which  is the first section to be executed  when the program runs. The word void before the  function main() means that this function does not return a  value and the second void inside the brackets means it  does not have any argument. When we run a program  the main() function is always executed first no matter  where it appears in the program. The body of main() Function . The body of the function main() is surrounded by braces {}. The left brace indicates the start of the body of the function and the right brace indicates the end of the body of the  function. Question 2: Define global and local variables. Ans : Variables are used in C program to store values. Global Variables:   Global variables are declared before the main() function.  These variables are use...

Programming In C, Structure of C, Preprocessor Directives

Image
Question:  Write the structure of C. Ans : T he format according to which a program is written is called the  structure of program. The following is the structure of a C program. Structure of C Language Structure of C Language Question: What are preprocessor directives? Describe its main types. Ans:   Preprocessor directives are instructions for the c compiler. Every C language program contains preprocessor directives at the beginning of the program. These directives start with number sign(#). The most commonly used preprocessor directives are include and define. ** The include Preprocessor Directives When this preprocessor is carried out by the c compiler, it will search for the header file that is written within the less than(<) and greater (>) symbols and copy it into the source file. In the above program the header file stdio.h is used. The Define Preprocessor Directives The define preprocessor is used for defining constants in c programs. It directs the compile...

Conditional Control structure ,Short Questions, Computer Science

Chapter # 4 Conditional Control structure SHORT QUESTIONS Question 1. What is control statement? Ans: A control statement is an instruction which determine the sequence of execution of other statements. In other words, it controls the flow of execution of program of program statements.   Question 1. What is conditional statement? Ans : A conditional statement is an instruction in a programming language that contains a condition.   When a conditional statement is executed, first the condition is evaluated then based on the result (True or False) a particular statement or a set of statements is executed. Conditional statements of c language are : if, if-else, else-if and switch statements.   Question 3. Explain the syntax and purpose of if statement with the help of a computer program? Ans : The if statement has the following general form. if(condition) { Block of statements } When this statement is executed the condition is evaluated. If the co...
Image
Question: Draw a flowchart to print the  multiplication table of a given number. Flowchart Question: Draw a flowchart to convert temperature from  Fahrenheit to Celsius Flowchart https://www.youtube.com/watch?v=xX8H6jCWOOo https://www.youtube.com/watch?v=sMNZMk_KCn4
Image
 Question: Describe the various flowchart symbols. Steps for drawing flowchart. Flowchart Symbols Question: Draw a flowchart to find the largest of three unequal numbers. Flowchart
Image
  Q1.Write an algorithm to find the exponent of a given number . Ans: Planning the Solution: Input: A number and its exponent. Required Output: Exponent of given number. Processing: Multiply the number as many times as its exponent. Algorithm: Step 1: Start Let the numbers, N be 8 and its exponent,                          E be 5. Step 2: Initialize product(P) and K to 1.                          P=1, K=1 Step 3: Find the Product(P)                          P=P*N Step 4: Increment K by 1.                          K=K+1 Step 5: Check if the value of K is less than or equal to E                If K ≤ E then goto step 3 otherwise goto step 6. S...
  Q1. What is problem solving? Ans:   Problem solving is the main task of  computer science which is the job of  computer programmer.  Q2. How we can analyze the problem? Ans:    At this stage of problem solving the  programmer investigates the problem and  gathers as much information as possible to find a solution.  Planning The Solution Of The Problem  Planning the solution of the problem is a creative  stage of problem solving.  After Analyzing the problem , the following.  planning is required. Q3.  How to discuss a problem? Talk to the person. Focus on talking about a problem. Stay calm and reasonable. Expect questions Candid Solution of a Problem. All the passible solutions of a problem that  produce correct result are known as  candid solutions.  After finding the candid solutions, only one solution can be selected based on the  criteria. 1. Speed 2. Cost  3.Complexity