C Theory and Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

1. Low Level Languages. 2. High Level Languages.

Low Level Languages


Low level computer languages are machine codes or close to it. Computer cannot understand instructions given in high level languages or in English. It can only understand and execute instructions given in the form of machine language i.e. language of 0 and 1. There are two types of low level languages:

Machine Language. Assembly Language

Machine Language: It is the lowest and most elementary level of Programming language and was the first type of programming language to be Developed. Machine Language is basically the only language which computer Can understand. In fact, a manufacturer designs a computer to obey just one Language, its machine code, which is represented inside the computer by a String of binary digits (bits) 0 and 1. The symbol 0 stands for the absence of Electric pulse and 1 for the presence of an electric pulse . Since a computer is Capable of recognizing electric signals, therefore, it understand machine Language.

Advantages of Machine Language


i) It makes fast and efficient use of the computer. ii) It requires no translator to translate the code i.e.Directly understood by the computer Disadvantages of Machine Language: i) All operation codes have to be remembered ii) All memory addresses have to be remembered. iii) It is hard to amend or find errors in a program written In the machine language iv) These languages are machine dependent i.e. a particular Machine language can be used on only one type of computer

Assembly Language
It was developed to overcome some of the many inconveniences of machine language. This is another low level but a very important language in which operation codes and operands are given in the form of alphanumeric symbols

instead of 0s and ls. These alphanumeric symbols will be known as mnemonic codes and can have maximum up to 5 letter combination e.g. ADD for addition, SUB for subtraction, START,LABEL etc. Because of this feature it is also known as Symbolic Programming Language. This language is also very difficult and needs a lot of practice to master it because very small English support is given to this language. The language mainly helps in compiler orientations. The instructions of the Assembly language will also be converted to machine codes by language translator to be executed by the computer.

Advantages of Assembly Language


i) It is easier to understand and use as compared to machine language. ii)It is easy to locate and correct errors. iii) It is modified easily

Disadvantages of Assembly Language


i) Like machine language it is also machine dependent. ii) Since it is machine dependent therefore programmer Should have the knowledge of the hardware also.

High Level Languages


High level computer languages give formats close to English language and the purpose of developing high level languages is to enable people to write programs easily and in their own native language environment (English). High-level languages are basically symbolic languages that use English words and/or mathematical symbols rather than mnemonic codes. Each instruction in the high level language is translated into many machine language instructions thus showing one-to-many translation

Types of High Level Languages


Many languages have been developed for achieving different variety of tasks, some are fairly specialized others are quite general purpose. These are categorized according to their use as a) Algebraic Formula-Type Processing. These languages are oriented towards the computational procedures for solving mathematical and statistical problem Examples are

BASIC (Beginners All Purpose Symbolic Instruction Code). FORTRAN (Formula Translation).

PL/I (Programming Language, Version 1). ALGOL (Algorithmic Language). APL (A Programming Language).

b) Business Data Processing:

These languages emphasize their capabilities for maintaining data processing procedures and files handling problems. Examples are: COBOL (Common Business Oriented Language). RPG (Report Program Generator

b) String and List Processing: These are used for string manipulation including search for patterns, inserting and deleting characters. Examples are:

LISP (List Processing). Prolog (Program in Logic).

Object Oriented Programming Language In OOP, the computer program is divided into objects. Examples are:

C++ Java

e) Visual programming language: these are designed for building Windows-based applications Examples are:

Visual Basic Visual Java Visual C

Advantages of High Level Language


Following are the advantages of a high level language:

User-friendly Similar to English with vocabulary of words and symbols Therefore it is easier to learn. They require less time to write. They are easier to maintain. Problem oriented rather than 'machine' based. Program written in a high-level language can be translated into many machine language and therefore can run on any computer for which there exists an appropriate translator.

It is independent of the machine on which it is used i.e.Programs developed in high level language can be run on any Computer

Disadvantages of High Level Language


A high-level language has to be translated into the machine language by a translator and thus a price in computer time is paid. The object code generated by a translator might be inefficient Compared to an equivalent assembly language program Types of computer languages As we human beings communicate with each others in different language such as Urdu, French, Punjabi and Arabic etc. Similarly to communicate with the computers we have to use specific languages and for this..

Basic Flowchart Symbols

The Process Symbol represents any process, function, or action and is the most frequently used symbol in flowcharting.

The Document Symbol is used to represent any type of hard copy input or output (i.e. reports).

Offpage Connector Symbols are used to indicate the flowchart continues on another page. Often, the page number is placed in the shape for easy reference.

The Input/Output Symbol represents data that is available for input or resulting from processing (i.e. customer database records).

Comment Symbols are used when additional explanation or comment is required. This symbol is usually connected to the symbol it is explaining by a dashed line.

The Decision Symbol is a junction where a decision must be made. A single entry may have any number of alternative solutions, but only one can be chosen.

The Connector Symbol represents the exit to, or entry from, another part of the same flowchart. It is usually used to break a flow line that will be continued elsewhere. It's a good idea to reference page numbers for easy location of connectors.
TYPES OF MEMORY SUMITA ARORA

Q.1 Explain the following questions in detail. 1) 2) 3) 4) 5) 6) 7) Write a note on Process of Compilation? Explain the Basic Structure of a Program in C Language? State significance of name main? What is Flowchart? List Guidelines for drawing Flowchart? Draw the basic symbol of flowchart? What is Algorithm? List Different ways of stating Algorithm? List Guideline for drawing algorithm explain with example? What do you understand by scope and lifetime of a variable? Describe various storage classes that a C Variable can have with example? List all categories of C Data type. Explain Basic data type in detail? Describe different types of operators that are included in C with Example. Q.2 Write a note on Following? Explain C Tokens in detail? What is identifier? Explain rules for naming an identifier? Explain use of escape sequence with an example? Explain Enumerated and typedef Data type with example? Explain Turnery operator in detail? Q.3 Differentiate the Following. Compiler Vs Interpreter Algorithm Vs Flowchart High level and Low level programming language Third Generation Vs Fourth Generation language Logical And Operator Vs Bitwise And Operator (&& Vs &)

1) 2) 3) 4) 5)

1) 2) 3) 4) 5)

Q.4 Write an Algorithm and Flowchart for the Following Find out the largest among the three numbers. Check weather a given number is krishnamurty number or not. i.e. Sum of factorial of every digit equal to original number. E.g. 145 = 1 + 24 + 120 = 145. 3) Compute the sum of the digits of any given number. 4) Print the Fibonacci Series up to N terms. 5) Find out the largest prime from N number. 1) 2) Q.5 Answer the following question in One or Two Line (Optional) 1) Who was the inventor of C and at which place? 2) Why is the C Language is called a middle level language? 3) List the different storage classes in C. 4) List the type of Constants in C 5) What is the return type of built in function printf() and scanf() 6) Which symbol is used to represent decision in a flowchart? 7) List the situation in which we will get run time error for the expression a/b 8) What is the difference between = and == ? 9) How can % symbol be printed using a printf() statement. 10) What is dynamic initialization?

Q.6 State Whether true or false. justify your answer with reason. (Optional) 1) X += Y*Z; is a Valid C Statement. 2) The header file stdio.h contains the definition of inbuilt functions printf and scanf 3) A C Variable can start with a number. 4) BASICSALARY is a valid variable name. 5) printf(%f,5/2); will gives output 2.5 6) The signed is a C Keyword. 7) 10.120 is a integer constants. 8) Identifiers are the name of variables, arrays, function, and so on. 9) A is a character constant. 10) India is a string constant. 11) _abc is a valid variable name. 12) int occupies 4 bytes in memory. 13) sizeof is an operator. 14) main is a keyword 15) In C variable SUM and sum are the same. Q.7 What will be the output of the following programs (Optional) 1). void main() { unsigned char c=90; printf(%d %c %d,c,c,c); } 2). void main() { int i=2,j=10,k; k = !((i<2) && (j>2)); printf(%d,k); } 3). void main() { int i,j=3,k; i=2*j/2; k=2*(j/2); printf(\n i=%d k=%d,i,k); } 4). void main() { int b,k=5; b=(k++ - k++ - k++,k++); printf(\nb=%d,b); } 5). void main() { int i=3,j=0; printf(%d, i++ + ++i + i-- + i++ + --i + ++i + ++i + i--); i=3; j= i++ + ++i + i-- + i++ + --i + ++i + ++i + i--; printf(%d,j);

Looping structure (while, do...while, for)


1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. Print 1 to 10. Print 2,4,6,8,10, Print 1,3,5,7,9, Print 1,2,4,8,16,32,64, Print 10 to 1 Print 1,10,2,9,3,8,4,7,5,6, Print 2,11,20,28,25,41,46,50,53,55,56, Print first 100 even numbers. Print first 100 odd numbers. Print first 50 natural numbers. Print the total of 1 to 50. Print the total of 1/2+2/3+....+9/10. Print the total of 1-2+3-4+5-6+7-8+9-10. Print the total of first 100 even numbers. Print the total of first 100 odd numbers. 0.1+0.02+0.003+0.0004+0.000005. Except one no from user and display Reverse of it. Except one no from user and display sum of its digits. Except one no from user and display its factorial. Except one no from user and find if it is prime or not. Except one no from user and find if it is Armstrong or not. Print 0 1 1 2 3 5 8 13 21 34 55 (Fibonanci series) Generate the value of n! factorial for n number 1+2+3+4+5+6 up to n terms 1+3+5+7+9 up to n terms 1+2+4+5+7+8 up to n terms Write a program that perform the following output for n by n matrix without using array 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 23 24 25 X+ X2 + X3 + X4 + X5 up to n terms X/Y + X2/Y2 + X3/Y3 up to n terms X/Y + X2/Y + X2/Y2 + X3/Y2 + X3/Y3 up to n terms A+AR+AR2+AR3+AR4 up to n terms 1! + 2! + 3! + 4! + 5! Up to n terms 1! + 3! + 5! + 7! Up to n terms X + X3 + X5 + X7 up to n terms X/1 + X2/22 + X3/33 + X4/44 up to n terms AB+CD+A2B2+C2D2 up to n terms Write a program to generate fibona series 0,1,1,2,3,5,8,13 up to n terms. 1*3 + (1+2) * 32 + (1+2+3) * 33 + (1+2+3+4) 34 up to n terms 1!/2! + 3!/4! + 5!/6! Up to n terms X/1! - X3/3! + X5/5! - X7/7! Up to n terms Write a program to calculate the sum of odd and even number between given no of series. (Perform all the exercises from 46 to 67 in following 3 patterns) Pattern-I Pattern-II

28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41.

Pattern-III

* ** *** **** ***** Nested looping structure.

* ** *** **** *****

* ** *** **** *****

42. Print pattern like follow. 12345 12345 12345 12345 12345 43. Print pattern like follow. 11111 22222 33333 44444 55555 44. Print pattern like follow. 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 1015 20 25 45. Print pattern like follow. AAAAA BBB BB CCCCC DDDDD E EE EE 46. Print pattern like follow. 1 22 333 44444 555555 47. Print pattern like follow. 1 12 123 1234 12345 48. Print pattern like follow. 5 54 543 5432 54321 49. Print pattern like follow. 1 21 321 4321 54321 50. Print pattern like follow. 1 2 3 4 5 6 7 8 9 10 1112131415

51. Print pattern like follow.

52.

53.

54.

55.

56.

57.

58.

59.

60.

61.

1 10 100 1000 10000 Print pattern like follow. 1 01 010 1010 10101 Print pattern like follow. 1 10 101 1010 10101 Print pattern like follow. a bb ccc dddd eeeee Print pattern like follow. a bc def ghij klmno Print pattern like follow. z y x wvu t s rq p onml Print pattern like follow. 5 45 345 2345 12345 Print pattern like follow. 12345 1234 123 12 1 Print pattern like follow. 12345 2468 369 48 5 Print pattern like follow. 54321 5432 543 54 5 Print pattern like follow.

62.

63.

64.

65.

66.

67.

68.

69.

70.

71.

1 72.

54321 4321 321 21 1 Print pattern like follow. 12345 2345 345 45 5 Print pattern like follow. 55555 4444 333 22 1 Print pattern like follow. 2 4 6 8 10 4 6 8 10 6 8 10 8 10 10 Print pattern like follow. abcde bcde cde de e Write a program that perform the following output for n rows 1 3 5 6 8 9 10 Write a program that perform the following output for n rows * * ** *** Write a program that perform the following output for n rows 1 1 2 1 2 3 1 2 3 4 Write a program to perform the following output for n rows 1 101 10101 Write a program to perform the following output for n rows 1* 2* * * 3* * * ** 4* * * * * ** Write a program that perform the following output for n rows 123454321 1234 4321 123 321 12 21 1 Write a program for following output for n no of rows( Pascal triangle)

1 1 1 1 1 4 3 6 2 3 4 1 1 1 1

You might also like