Académique Documents
Professionnel Documents
Culture Documents
Introduction to
Programming
Languages and
Programming
1. Explain with examples the concept of (i) Encapsulation (ii) Inheritance (iii) Operator
Overloading (iv)Function overloading and (v) friend function in object oriented
programming. 10 October-2014
2. Explain with examples the concepts of encapsulation, inheritance, operator
overloading, function overloading and friend function that are used in an object
oriented programming language. April-2014
3. Explain with examples the syntax errors, runtime errors, and logical errors that you
can encounter when writing computer programs. What are the steps that are
followed to debug these problems of a program? 10 April-2014
4. You have an array A of 100 elements. Write a program using any high level language
of your choice, which finds and displays the odd numbers of the array. April-2014
5. Name three programming languages. Using the appropriate computer program,
explain the steps involved from writing a computer program to its execution. 10
April-2003
6. Name three popular high level programming languages. Write a small program in
any of the languages to compute the sum of two real numbers and display the result
on the monitor. 10 April-2004
7. What is flow chart? Device a flow chart that finds out the highest mark obtained in
an examination. Assume that only one student obtained the highest mark. 7 April2005
8. Write a program using C, C++ or FORTRAN which reads two integer numbers from
a keyboard and prints their sum to the computer console. 8 April-2005
9. What do you understand by the term Programming Language? Classify
programming languages and explain each of them with examples. Distinguish
between a compiler and an interpreter. 10 April-2007
10. Describe, with examples, the difference between low level and high-level
programming languages used in computers. What do you understand by the term
Object Oriented Programming? 10 October-2007
11. What is a flow chart? Five numbers denoted by the variables A, B, C, D and E are
supplied as input. Draw a flow chart for the logic to print these numbers in
descending order of magnitude. 2+8 April-2008
12. A set of examination papers, which have been graded with scores from 0 to 100 is to
be searched to find how many of them are above 90. Prepare of flowchart to do this
job.
10 April-2008
Page 1 of 157
S M TALHA JUBAED
+88-01911-088706
13. Distinguish between machine language, assembly language and high level language.
Mention the types of errors that can be occur in a computer program. 6+4 April-2008
14. What is a compiler? What types of errors can be detected by a compiler? Mention the
advantages of high level languages over machine languages. 3+3+4 October-2008
15. What is a debugger? How does it help a programmer? 5 October-2008
16. What are program comments? Why are they needed? 5 October-2008
17. What is an algorithm and what is a flowchart? Three numbers denoted by the
variables A, B and C are supplied as input data. Draw a flow chart for the logic to pick
and print the largest of the three numbers. 4+6 October-2008
18. Draw a flowchart to add up all the even numbers between 0 and 100. In the same job,
the results of the calculation are to be printed before ending. 10 October-2008
19. What is a compiler? What is the difference between a compiler and an interpreter?
What types of errors are detected by a compiler?
2+4+4 April-2009
20. Write the advantages and limitations of machine language and assembly language.10
April-2009
21. What is a compiler? What is the difference between a compiler and an interpreter?
What types of errors are detected by a compiler?
2+4+4 October-2009
22. Draw a flowchart to add up all the even numbers between 0 100. Before ending,
print the result of the calculation. 10 October-2009
23. Give a flow chart for the following problem. Read data values and keep on adding
them until negative value is entered. Output the sum and the number of data values
read and added. 10 April-2010
24. Write a program for the problem in 4(a) using any programming language.
10
April-2010
25. What is a compiler? What types of errors are detected by a compiler? 6 April-2010
26. Draw a flow chart for the summing up first N positive integers. 10 October-2010
27. Write a program for the problem in 4(a) using any programming language.
10
October-2010
28. What is a high level language? What features are necessary in a high level language?
5 October-2010
29. Discuss the differences between a procedural programming language and an object
oriented programming language. 10 October-2010
30. What is an algorithm? What is a flowchart? 4 April-2011
31. Draw a flowchart of the logical steps needed to print the name and age of the oldest
and youngest student in a class. The input contains the name and age of the students.
8 April-2011
32. Write a program in a high-level language for the problem in question no 6(b).
8
April-2011
33. What is an Interpreter? How does it differ from a compiler? 5 April-2011
34. What types of errors can be detected by a compiler? What type of errors cannot be
detected? 5 April-2011
35. What are the advantages and limitations of a machine language? 5 April-2011
36. Explain the differences between a source program and an object program. 5 April2011
37. What is a compiler? What types of errors can be detected by a compiler? 5 October2011
38. What are the advantages and limitations of an assembly language? 5 October-2011
Page 2 of 157
S M TALHA JUBAED
+88-01911-088706
39. Explain the difference between a source program and an object program. 5 October2011
40. Write the advantages of a high level programming language. 5 October-2011
41. Give a flow chart to find the largest value of given numbers.10 October-2011
42. Write a program for the problem in 5(a) using any programming language.
10
October-2011
43. What is an Interpreter? How does it differ from a compiler? 5 April-2012
44. What are the advantages and limitations of a machine language?
5 April-2012
45. What types of errors can be detected by a compiler? What types of errors cannot be
detected by a compiler? 5 April-2012
46. Describe any two basic services provided by Internet. 5 April-2012
47. What is an algorithm? What is a flowchart? 4 April-2012
48. Give a flow chart for the following problem. Read data values and keep on adding
them until negative value is entered. Output the sum and the number of values read
and added. 8 April-2012
49. Write a program for the problem in 48 using any programming language. 8 April2012
50. Write a program to find the maximum of three given numbers taken as input. 8
October-2012
51. Given an integer, write a program to find the summation of all digits of the given
integer number. 8 October-2012
52. Write a program to swap the values of two variables. 4 October-2012
53. What do you mean by the machine code of a CPU? 5 October-2012
54. What are the differences between a high level programming language and a low-level
programming language? 3 October-2012
55. What do you mean by pseudo-code of a program? 2 October-2012
56. Write a loop that will run indefinitely. 2 April-2013
57. Write a program to find summation, average, maximum and minimum of numbers.
8 April-2013
58. What are the usages of continue and break statements in a programming language?
4 April-2013
59. Write a program that takes an year as an input, and gives yes as output if the given
year is a leap year and No as output if the year is not a leap year. 5 April-2013
60. Write a function to find the length of a given string. 3 April-2013
61. What are the differences between a structured programming language and an object
oriented programming language? 4 April-2013
62. Write a program, using any high-level language, which reads three numbers from the
keyboard, and outputs the minimum and maximum values. Also write the output of
the following program segment. 8 October-2013
int i, j, k;
k=2;
j = 10;
i = 5;
while( ) {
printf(i=%d, j=%d and k=%d, i, j, k);
j=j-2;
Page 3 of 157
S M TALHA JUBAED
+88-01911-088706
}
63. Explain the three properties of an object oriented programming language. What are
the steps that are followed to debug a program? 6 October-2013
64. Compare while and for loops that are used in a programming language. List the
names an symbols of the logical and relational operators that are used in C/C++. 6
October-2013
65. Write a program, using any high-level language, which asks the user to enter the
radius of a sphere, and then computes and displays the spheres area and volume
4
where = 4 2 and = 3 . 8 October-2013
3
66. Write a program to find the maximum, minimum and summation of 50 numbers. 10
October-2014
67. Draw a flowchart of the logical steps needed to print the name and age of the oldest
student in a class. 10 April-2009
Page 4 of 157
S M TALHA JUBAED
+88-01911-088706
Page 5 of 157
S M TALHA JUBAED
+88-01911-088706
Page 6 of 157
S M TALHA JUBAED
+88-01911-088706
Its machine dependent language i.e. individual program required for each machine.
To develop a program in machine language, its too hard to understand and program.
Its time consuming to develop new programs.
Debugging process is very hard because of finding errors process is typical.
Machine language is not portable language.
BASEPAY
ADD
OVERPAY
STORE
GROSSPAY
Its a machine dependent language due to that program design for one machine no use
of other machine.
Sometime its hard to understand the statement or command use.
Page 7 of 157
S M TALHA JUBAED
+88-01911-088706
HLL programming language take more space compare to other MLL (machine level
language) and/or ALL (Assembly level language).
This programming language execute slowly.
Interpreter
Interpreter Takes Single instruction as input .
No Intermediate Object Code is Generated
Conditional Control Statements are Executes
slower
Memory Requirement is Less
Page 8 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] https://en.wikipedia.org/wiki/Programming_language
[2] http://er.yuvayana.org/definition-classification-of-computer-programming-languages/
[3] http://www.c4learn.com/c-programming/compiler-vs-interpreter/
Page 9 of 157
S M TALHA JUBAED
+88-01911-088706
Page 10 of 157
S M TALHA JUBAED
+88-01911-088706
Page 11 of 157
S M TALHA JUBAED
+88-01911-088706
Page 12 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://www.programiz.com/article/difference-compiler-interpreter
Page 13 of 157
S M TALHA JUBAED
+88-01911-088706
Lets get some of our concepts clear before to head on to programming in java.This and perhaps
next few posts will help you clear some computer programming concepts.
Both compiler and interpreter convert human readable high level language like Java,C++ etc
into machine language but there is difference in the way both function.So lets take a look to
understand the differences.
Difference between Compiler and Interpreter
Compiler scans the entire program once and then converts it into machine language
which can then be executed by computer's processor.In short compiler translates the
entire program in one go and then executes it. Interpreter on the other hand first
converts high level language into an intermediate code and then executes it line by line.
This intermediate code is executed by another program.
What is Assembler?
Page 14 of 157
S M TALHA JUBAED
+88-01911-088706
As our basics are now clear lets get on to Java. Well you must have heard that Java is both
compiled and interpreted language. When it comes to the question - How Java works? It goes
something like below
When you run javac HelloWorld.java java compiler is invoked which converts human
readable code(Contents of .java file) to java byte codes(intermediate form). This
bytecodes are stored in a special file(called Class file) with .class extension.
Finally when you run java HelloWorld java interpreter is invoked which reads these
bytecodes line by line, convert it into machine language and execute it.
Page 15 of 157
S M TALHA JUBAED
+88-01911-088706
Divided Into
Importance
Approach
Access
Specifiers
Data Moving
Expansion
Data Access
Data Hiding
Overloading
Examples
Reference:
[1]
http://freefeast.info/general-it-articles/difference-between-procedure-oriented-programmingand-object-oriented-programming-procedure-oriented-programming-vs-object-orientedprogramming/
Page 16 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1]
https://neonbrand.com/website-design/procedural-programming-vs-object-orientedprogramming-a-review/
Page 17 of 157
S M TALHA JUBAED
+88-01911-088706
Page 18 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://studentstudyhub.blogspot.com/2012/10/difference-between-machineassembly-and.html
[2] https://msdn.microsoft.com/en-us/library/s9ek7a19%28v=vs.90%29.aspx
Page 19 of 157
S M TALHA JUBAED
+88-01911-088706
Usually, the errors become more difficult to find and fix as you move down the above list.
Syntax errors
Syntax errors represent grammar errors in the use of the programming language. Common examples
are:
Syntax errors are the easiest to find and fix. Over the years, compiler developers have worked hard to
make compilers smarter so that they can catch errors at compile time that might otherwise turn out to
be runtime errors.
Examples:
1. Simple statement not terminated by semicolon:
Page 20 of 157
S M TALHA JUBAED
+88-01911-088706
Linker errors
Linker errors are generated when the linker encounters what looks like a function call; but it
cannot find a function with that name. This is usually caused by misspelling a C standard
function (like main) or not including the header file for a function.
Page 21 of 157
S M TALHA JUBAED
+88-01911-088706
Note: Dev C++ has an option that automatically includes standard header files. It is not recommended
to use this option, as it is CPU-intensive. To turn off this option use the menus: Tools Compiler
Options Settings Linker and set "Do not use standard system startup files or libraries" to Yes:
With the option turned off, not including a standard header file in your program will generate a linker
error:
Page 22 of 157
S M TALHA JUBAED
+88-01911-088706
Runtime errors
A type of error that occurs during the execution of a program is known as run-time error.
Runtime errors may crash your program when you run it. Runtime errors occur when a
program with no syntax errors directs the computer to execute an illegal operation. Common
examples are:
There is no way for the compiler to know about these kinds of errors when the program is compiled.
Runtime errors are commonly due to wrong input from the user. Runtime errors are usually more
difficult to find and fix than syntax errors.
To find the source of a run-time error in a program, usually a software called debugger is used.
Example: When the following program is executed and the user inputs 0 for num2, a run-time
error occurs due to division by zero in the expression num1 / num2
#include <stdio.h>
#include <stdlib.h>
Page 23 of 157
S M TALHA JUBAED
+88-01911-088706
Logic errors
Logic errors occur when a programmer implements the algorithm for solving a problem
incorrectly. A statement with logical error may produce unexpected and wrong results in the
program. Common examples are:
Logic errors can only be detected by examining the program thoroughly. This is usually done by using
a debugger.
Example: The following program has a logic error in the 3rd printf statement
#include <stdio.h>
#include <stdlib.h>
Page 24 of 157
S M TALHA JUBAED
+88-01911-088706
Exercise: Copy and paste the program below in Dev C++ editor. Save the program using an
appropriate name. Determine, classify and correct all errors in the program by compiling and
executing the program:
#include <stdio.h>;
#include <stdlib.h>;
int main(void); {
int num1;
printf('Enter the first integer: ');
scanf("%d", &num1);
printf("\nEnter the second integer: ";
scanf("%d", &num2);
Printf("\n%d * %d = %c\n", num1, num2, num1 + num2);
system("PAUSE";
return 0;
}
Reference:
[1] http://faculty.kfupm.edu.sa/ICS/said/ics103_101/Lab02%20Supplement2Types%20of%20Program%20Errors.doc
Page 25 of 157
S M TALHA JUBAED
+88-01911-088706
Page 26 of 157
S M TALHA JUBAED
+88-01911-088706
Page 27 of 157
S M TALHA JUBAED
+88-01911-088706
Page 28 of 157
S M TALHA JUBAED
+88-01911-088706
Page 29 of 157
S M TALHA JUBAED
+88-01911-088706
Page 30 of 157
S M TALHA JUBAED
+88-01911-088706
Page 31 of 157
S M TALHA JUBAED
+88-01911-088706
Page 32 of 157
S M TALHA JUBAED
+88-01911-088706
Page 33 of 157
S M TALHA JUBAED
+88-01911-088706
Page 34 of 157
S M TALHA JUBAED
+88-01911-088706
Page 35 of 157
S M TALHA JUBAED
+88-01911-088706
1. See the error. This is easy if you spot the error, but not if it comes from a user, in that
case see if you can get the user to send you a few screen captures or even use remote
connection to see the error by yourself.
2. Reproduce the error. You never should say that an error has been fixed if you were not
able to reproduce it.
3. Understand what the expected behavior should be. In complex applications could be
hard to tell what should be the expected behavior of an error, but that knowledge is
basic to be able to fix the problem, so we will have to talk with the product owner,
check documentation to find this information
4. Validate the identification. Confirm with the responsible of the application that the
error is actually an error and that the expected behavior is correct. The validation can
also lead to situations where is not necessary or not worth it to fix the error.
Step 2. Find the error.
Once we have an error correctly identified, is time to go through the code to find the exact spot where
the error is located, at this stage we are not interested in understanding the big picture for the error,
we are just focused on finding it. A few techniques that may help to find an error are:
Logging. It can be to the console, file It should help you to trace the error in the code.
Debugging. Debugging in the most technical sense of the word, meaning turning on
whatever the debugger you are using and stepping through the code.
Removing code. I discovered this method a year ago when we were trying to fix a very
challenging bug. We had an application which a few seconds after performing an action
was causing the system to crash but only on some computers and not always but only
from time to time, when debugging, everything seemed to work as expected, and when
the machine was crashing it happened with many different patterns, we were
completely lost, and then it occurred to us the removing code approach. It worked
more or less like this: We took out half of the code from the action causing the machine
to crash, and we executed it hundreds of times, and the application crashed, we did the
same with the other half of the code and the application didnt crash, so we knew the
error was on the first half, we kept splitting the code until we found that the error was
on a third party function we were using, so we just decided to rewrite it by ourselves.
Page 36 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://www.makinggoodsoftware.com/2009/06/14/7-steps-to-fix-an-error/
Page 37 of 157
S M TALHA JUBAED
+88-01911-088706
Think about what the program must have done in order to produce the results it did.
This will lead you to where the error must have occurred.
Put in print statements to help you figure out what the program is actually doing.
Use a debugger to step through your program and watch what it does.
Reference:
[1] https://www.cis.upenn.edu/~matuszek/General/JavaSyntax/errors.html
Page 38 of 157
S M TALHA JUBAED
+88-01911-088706
Study the requirement specification for the application. It is important that the requirements of
the application should be well specified. Before starting to design a program for the application
it is necessary that the requirement specification is complete and consistent. For example a
requirement specification that says `write a program to solve equations' is obviously incomplete
and you would have to ask for more information on `what type of equations?', `how many
equations?', `to what accuracy?' etc.
Analyse the problem and decide how to solve it. At this stage one has to decide on a method
whereby the problem can be solved, such a method of solution is often called an Algorithm.
Translate the algorithm produced at the previous step into a suitable high-level language. This
written form of the program is often called the source program or source code. At this stage the
program should be read to check that it is reasonable and a desk-check carried out to verify its
correctness. A programmer carries out a desk-check by entering a simple set of input values and
checking that the correct result is produced by going through the program and executing each
instruction themselves. Once satisfied that the program is reasonable it is entered into the
computer by using an Editor.
Compile the program into machine-language. The machine language program produced is called
the object code. At this stage the compiler may find Syntax errors in the program. A syntax error
is a mistake in the grammar of a language, for example C++ requires that each statement should
be terminated by a semi-colon. If you miss this semi-colon out then the compiler will signal a
syntax error. Before proceeding any syntax errors are corrected and compilation is repeated
until the compiler produces an executable program free from syntax errors.
The object code produced by the compiler will then be linked with various function libraries that
are provided by the system. This takes place in a program called a linker and the linked object
code is then loaded into memory by a program called a loader.
Run the compiled, linked and loaded program with test data. This may show up the existence of
Logical errors in the program. Logical errors are errors that are caused by errors in the method
of solution, thus while the incorrect statement is syntactically correct it is asking the computer
to do something which is incorrect in the context of the application. It may be something as
simple as subtracting two numbers instead of adding them. A particular form of logical error
that may occur is a run-time error. A run-time error will cause the program to halt during
execution because it cannot carry out an instruction. Typical situations which lead to run-time
errors are attempting to divide by a quantity which has the value zero or attempting to access
data from a non-existent file.
The program must now be re-checked and when the error is found it is corrected using the
Editor as in (3) and steps (4) and (5) are repeated until the results are satisfactory.
The program can now be put into general use - though unless the testing was very
comprehensive it is possible that at some future date more logical errors may become apparent.
It is at this stage that good documentation produced while designing the program and writing
the program will be most valuable, especially if there has been a considerable time lapse since
the program was written.
Reference:
COMPUTER FUNDAMENTALS INTRODUCTION TO COMPUTERS
+88-01719-033364
Page 39 of 157
S M TALHA JUBAED
+88-01911-088706
Page 40 of 157
S M TALHA JUBAED
+88-01911-088706
Determine program logic through top down approach and modularization, using a
hierarchy chart
Page 41 of 157
S M TALHA JUBAED
+88-01911-088706
Page 42 of 157
S M TALHA JUBAED
+88-01911-088706
Alpha testing is the process of reading through the program in search of errors in logic.
The second step is to run a diagnostic program to search for syntax or input errors.
Beta testing involves using the program in the real world to see if it contains any bugs
or other deficiencies.
Reference:
[1]
https://en.wikibooks.org/wiki/The_Computer_Revolution/Programming/Five_Steps_of_Programming
Page 43 of 157
S M TALHA JUBAED
+88-01911-088706
High-level Language
High-level languages are easy to learn.
High-level languages are near to human
languages.
Programs in high-level languages are slow
in execution.
Programs in high-level languages are easy
to modify.
Facility at hardware
level
Knowledge of
hardware Deep
Uses
Low-level languages
Low-level languages are
difficult to learn.
Low-level languages are far
from human languages.
Programs in low-level
languages are fast in execution.
Programs in low-level
languages are difficult to
modify.
Low-level languages provide
facility to write programs at
hardware level.
Deep knowledge of hardware is
required to write programs.
These languages are normally
used to write hardware
programs.
Reference:
[1] http://iamcomputerexpert.blogspot.com/2008/09/difference-between-low-level-high-level.html
Page 44 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://searchsoftwarequality.techtarget.com/definition/debugging
Page 45 of 157
S M TALHA JUBAED
+88-01911-088706
[2] http://queue.acm.org/detail.cfm?id=1053354
[3] http://www.cprogramming.com/tutorial/comments.html
Page 46 of 157
S M TALHA JUBAED
+88-01911-088706
1. Identify the problem: What problem does your program solve? If you can't clearly state
what your program does, you won't know how to design it.
2. Identify the user: Who's going to use your program?
3. Determine the target computer: Which computer do people need to run your program?
Is it a Windows computer, a Macintosh, a mainframe, a computer running Linux, a
handheld Palm or Pocket PC, or a supercomputer?
4. Determine your programming skill: Are you going to write the entire thing yourself or
get help from others? If you're going to get others to help you, which parts of the
program are they going to write?
Computer programming: Identify the problem
Every program solves a problem. A tax return program solves the problem of organizing and filing your
taxes. A word processor solves the problem of writing, editing, formatting, and printing text. Even a
video game solves the problem of keeping people amused.
A program is only as useful as the problem it solves. Most programs simplify and automate an existing
problem, such as a money management program that simplifies organizing and paying bills instead of
using paper and an adding machine. The goal of any program is to make a specific task faster, easier, and
more convenient. The only way reach that goal is to identify what task your program is trying to solve
in the first place.
Identify the computer program's users
If you're the only person who's going to use your program, you can pretty much make your program
look and act any way you want, just as long as you know how to make it work. But if you plan to give or
sell your program to others, you need to know who's going to use it.
Knowing your program's typical user is critical. If users don't like your program for any reason, they're
unlikely to use it. Whether the program actually works is often irrelevant.
By designing your program with the user in mind, you increase the odds that people use your program
and (you hope) buy a copy for themselves.
Even if you write a program that works perfectly, users still may ignore it because they don't like the
way it looks, they don't understand how to give it commands, it doesn't work the same way as the old
program they currently use, the colors don't look right to them, and so on. The goal is to make your
program meet your users' needs, no matter how weird, bizarre, or illogical they may seem (the needs
not the users).
Determine the target computer for your computer program
Page 47 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1]
http://www.dummies.com/how-to/content/four-steps-to-take-before-writing-computerprogram.html
Page 48 of 157
S M TALHA JUBAED
+88-01911-088706
Easy to learn:-
The high Level Languages are close to human languages. The instructions written in
high level languages are similar to English like words and Statements. This makes the high level
languages easy to learn and use.
The logic of the program written in high level languages is very simple and easy. The
instructions of program are like English language statements. In case of errors, it is very easy
to detect (or find) and remove errors in the Program. It is also easy to modify the Program.
Machine Independent:-
Page 49 of 157
S M TALHA JUBAED
+88-01911-088706
For Example:-
Every High Level Language provides a large number of Built in functions (or library
functions) that can be used to perform specific tasks during designing of new Programs.
For Example:
To computer the square root of a number, the programmer can use the available built
in function without writing its own code. This way of writing a program reduces the
development time of a program. This software is developed in a very short time.
Shorter Program:-
The Program written in high level language is shorter than the program written in
low level language. A single instruction of the program written in High Level Language may be
equivalent to many instructions of low level programming language.
Every high level language has a standard syntax. The standard is approved (or
established) by international organization. The most popular organization is ANSI (American
National Standard Institute). The translator programs are written according to the standard
syntax of the language. Therefore, high level languages describe a well defined way of writing
programs.
The instructions of the program written in high level language are like English
language statements. These are written according to the standard syntax of the language.
Therefore, a computer programmer can easily understand a program written by another
programmer.
Reference:
[1]
http://cprogramming007.blogspot.com/2012/01/characteristics-of-high-levellanguages.html
Page 50 of 157
S M TALHA JUBAED
+88-01911-088706
Page 51 of 157
S M TALHA JUBAED
+88-01911-088706
2. C
What is it?
C, a general purpose programming language built by Dennis Ritchie when he was a part of Bell
Telephone labs, is the bass of C++ and other programming languages. It was built to work with
the Unix operating system.
Why is it important?
C is one of the most widely used programming languages of all time, and ranked second on the
list. Learning C is crucial. Once you learn C, making the jump to Java or C# is fairly easy, because
a lot of the syntax is common. Also, a lot of C syntax is used in scripting languages, Wayne
Duqaine, director of Software Development at Grandview Systems, of Sebastopol, Calif., told
eWEEK.
3. C#
What is it?
This general-purpose programming language developed by Microsoft evolved from C and C++
as
a
part
of
the
software
companys
.NET
initiative.
Why is it important?
COMPUTER FUNDAMENTALS INTRODUCTION TO COMPUTERS
+88-01719-033364
Page 52 of 157
S M TALHA JUBAED
+88-01911-088706
What is it?
C++ is a general purpose multi-paradigm spanning compiled language that has both high-level
and low-level languages features. It was started as an enhancement to the C programming
language, Bjarne Stroustrup in 1979.
Why is it important?
It is one of the most popular programming languages, winning fourth place on the list, with
application domains including systems software, application software, server and client
applications, and entertainment software such as video games. The language has also greatly
influenced many other popular programming languages, such as C# and Java.
5. Objective-C
What is it?
This object-oriented programming language created first by Brad Cox and Tom Love at their
company Stepstone in the early 1980s, adds Smalltalk-like messaging to the C programming
language.
Why is it important?
This language is most used on the Apple iOS and Mac OS X. Objective-C is the principal language
used for Apple's Cocoa API as well.
Page 53 of 157
S M TALHA JUBAED
+88-01911-088706
6. PHP
What is it?
This language is especially suited for Web development because of it easy embedding into
HTML pages. It is an open-source, server-side, cross-platform, interpretive HTML scripting
language
Why is it important?
It is a popular language, ranking sixth on TIOBEs list. "High-speed scripting with caching,
augmented with compiled code plug-ins (such as can be done with Perl and PHP) is where the
future is. Building Web apps from scratch using C or COBOL is going the way of the dinosaur,"
said
Duquaine,
according
to
eWEEKs
report.
7. (Visual) Basic
What is it?
This is an event-driven programming language which is implemented on Microsofts .Net
framework.
Why is it important?
This language ranked as the seventh most popular language on TIOBEs list, probably because
it was designed by Microsoft to be easy to learn and use. According to Tim Huckaby, CEO of San
Diego-based software engineering company CEO Interknowlogy.com, It is currently
dominating in adoption and that is where all the work is, as in eWEEKs report.
8. Python
What is it?
This is an event-driven programming language which is extensively used by Google because of
its simplicity. It is managed by the Python Software Foundation.
Why is it important?
Python is a general-purpose, high-level programming language whose design philosophy
emphasizes code readability. Python claims to combine "remarkable power with very clear
syntax", and its standard library is large and comprehensive.
COMPUTER FUNDAMENTALS INTRODUCTION TO COMPUTERS
+88-01719-033364
Page 54 of 157
S M TALHA JUBAED
+88-01911-088706
Why is it important?
Perls efficiency in processing of piles of text has ranked it ninth in terms of programming
language popularity. It is used extensively to write Web server programs for a variety of tasks.
Learning some form of scripting language, such as Perl or PHP is critical if you are doing Web
apps," told Wayne Duqaine, director of Software Development at Grandview Systems, of
Sebastopol,
Calif.,
in
a
talk
with
eWEEK.
10. JavaScript
What is it?
JavaScript is an object-oriented scripting language that is smaller than Java. Being a client-side
language, it runs in the web browser on the client-side with a simplified set of commands, easier
code
and
no
need
for
compilation.
Why is it important?
JavaScript is simple to learn and is the tenth most widely used programming language. It is used
in millions of web pages to authenticate forms, detect browsers and improve design, and it is
easier to run these functions as it is embedded into HTML.
Reference:
[1] http://www.freerepublic.com/focus/chat/2880277/posts
Page 55 of 157
S M TALHA JUBAED
+88-01911-088706
1. C Language
Page 56 of 157
S M TALHA JUBAED
+88-01911-088706
3. Java
Java was developed by James Gosling, in 1990 at Sun Microsystems. Java further adds to the capabilities
of C++ language. It is often said that Java owes a lot to C and C++ in terms of features and capabilities.
The special thing about Java is that this is the first purely object oriented programming language. Java
was developed on the principle of WORA i.e. Write Once Run Anywhere. This feature adds to the
portability of Java. You just need to compile Java Source code once and then on any machine where JVM
(Java Virtual Machine is installed), you can run that code irrespective of the underlying operating system
and hardware.
Page 57 of 157
S M TALHA JUBAED
+88-01911-088706
Page 58 of 157
S M TALHA JUBAED
+88-01911-088706
6. PHP
PHP (Hypertext Preprocessor) is one of the most widely used languages used to develop dynamic
websites. PHP was developed in 1995 and is a server-side scripting language which means that PHP
code is processed on the server and end result is sent to the user of the website in the form of plain
HTML.
PHP is an open-source language which means that there are thousands of already built modules that can
be modified to achieve the desired functionality. Also, PHP is easy to learn; you simply have to embed
the code inside HTML. And if there was anything left, there are hundreds of PHP platforms available
such as Joomla, WordPress, and Drupal that allow you to develop websites even more conveniently. PHP
is one language that every programmer should learn if he or she plans to pursue a web developers
career. PHP is also an integral part of the famous LAMP (Linux Apache MySQL and PHP) platform that
Facebook, Yahoo, and other famous websites use. PHP has a huge job market, though not much highly
paid when compared to ASP.NET developers; PHP developers easily find decent jobs. Some easy and
comprehensive tutorials are available at Udemy PHP.
7. JavaScript
Server side languages are ideal for developing complex web applications but performing every task on
server puts lots of load on a server. For this reason, developers often delegate some part of the
functionality to client side and for this purpose JavaScript is used. JavaScript is a client side
programming language that runs inside a client browser and process commands on client computer
rather than server which results in decreased load on server and increased applications execution
speed. JavaScript has been designed by Netscape and there is hardly any website that doesnt make use
of JavaScript. Though, JavaScript alone will not help you land a job but if you are looking to pursue a
career in web development, JavaScript is a must learn language along with some advanced server side
scripting language. A good resource to learn Java is available at Udemy.com. Join over a thousand
students who have taken this course on comprehensive JavaScript programming.
Page 59 of 157
S M TALHA JUBAED
+88-01911-088706
8. Python
Python is another high-level programming language and is often considered on the easiest language to
learn, owing to its simplicity, readability and straight forward syntax. Python was developed by Guido
Van Rossum in 1991. Python wasnt used that widely in the past; however, the language has seen great
surge in popularity in the recent years owing to Googles investment in the language in the past 10 years
or so. Currently, some highly famous and robust sites are operating in python including pinterest.com,
instagram.com, and rdio.com. Like, PHP, Python also has associated web frameworks which make it
more convenient to develop web based applications in python. Django is one such platform which
powers the sites aforementioned. There are two renowned courses on Python for beginners that Id like
to recommend: this course on Python programming and this Ultimate Python Tutorial.
9. SQL
SQL is not a development language; it is actually a database query language. SQL stands for Structured
Query Language. SQL provides a standardized way of interacting with the underlying database of an
application. SQL is extremely simple to learn and is probably closest to the English language in terms of
syntax. Almost every application has a backend database and in order to interact with that you will need
to have sound knowledge of SQL. Like JavaScript, SQL alone is not that beneficial in terms of job
placement; however, good command of SQL can help you stand out of crowd. Therefore, it is highly
recommended that you learn it. You can try out this beginners SQL crash course to start!
10. Ruby
Similar to Python, Ruby is also a simple and readable programming language mainly focused on
developing web-based applications. Designed by Yukihiro Matsumoto in 1995, Ruby powers Ruby on
Rails, a web development framework on which numerous renowned websites including Github, Scribd,
Yammer, Shopify, and Groupon have been developed. Ruby is regarded as combination of some of the
most famous features of Lisp, Pearl and Eiffel. Ruby also has got a good job market and ruby developers
are being paid decently at the moment. Learn Ruby quickly and painlessly with this course!
Page 60 of 157
S M TALHA JUBAED
+88-01911-088706
Languages
TIOBE
1
4
2
6
3
JobsTractor
Vacancies
Rank
at
Indeed.com
13
8112
10
31199
1
67753
8
31935
3
4473
5
8
11
2
9
5
Rank
C
C++
Java
C#
ObjectiveC
PHP
Python
Ruby
19953
24916
13621
I have explained ten of the most famous and usable programming languages that
one should learn, but the question still lingers that which language is the best. Unfortunately, only you
can answer this question. Apart from considering the stats that I mentioned in the last section, following
are some of the factors that you should take into account while selecting a particular language for
development.
What the requirements of the application you want to develop are; web-based, desktop
or mobile application?
What your personal interests are; commercial or open source technologies?
What the job market of the language is.
Learning curve for a particular language.
Though these are some general guidelines, in the current market where job competition is at its peak,
you must be proficient in at least one web-based language, one desktop based programming language,
and at least one mobile platform, in order to distinguish yourself among contemporary programmers.
Reference:
[1] https://blog.udemy.com/best-programming-language/
Page 61 of 157
S M TALHA JUBAED
+88-01911-088706
Flowcharts
Question: What is Flowchart? What are the advantages and limitations of Flowcharts?
Flowcharts:
A flowchart is a graphical representation of the sequence of operations in an information
system or program. Program flowcharts show the sequence of instructions in a single program or
subroutine.
Flowchart uses boxes of different shapes to denote different types of instructions. The actual
instructions are written within these boxes using clear and concise statements. These boxes are
connected by solid lines having arrow marks to indicate the flow of operation, that is, the exact sequence
in which the instructions are to be executed. Since a flowchart shows the flow of operations in pictorial
form, any error in the logic of the procedure can be detected easily. Once the flowchart is ready, the
programmer can forget about the logic and can concentrate only on coding the operations in each box
of the flowchart in terms of the statements of the programming language. This will normally ensure an
error-free program.
Advantages of Flowcharts
Conveys Better Meaning
Since a flowchart is a pictorial representation of a program, it is easier for a programmer to understand
and explain the logic of the program to some other programmer.
Analyses the Problem Effectively
A macro flowchart that charts the main line of logic of a software system becomes a system model that
can be broken down into detailed parts for study and further analysis of the system.
Effective Joining of a Part of a System
A group of programmers are normally associated with the design of large software systems. Each
programmer is responsible for designing only a part of the entire system. So initially, if each
programmer draws a flowchart for his part of design, the flowcharts of all the programmers can be
placed together to visualize the overall system design. Any problem in linking the various parts of the
system can be easily detected at this stage and the design can be accordingly modified. Flowcharts can
thus be used as working models in the design of new programs and software systems.
Efficient Coding
Once a flowchart is ready, programmers find it very easy to write the concerned program because the
flowchart acts as a roadmap for them. It guides them in proceeding from the starting point of the
program to the final point ensuring that no steps are omitted. The ultimate result is an error free
program developed at a faster rate.
Systematic Debugging
Even after taking full care in program design, some errors may remain in the program because the
designer might have never thought about a particular case. These errors are detected only when we
start executing the program on a computer. Such type of program errors are called bugs and the process
of removing these errors is known as debugging. A flowchart is very helpful in detecting, locating, and
removing mistakes (bugs) in a program in a systematic manner.
Systematic Testing
Testing is the process of confirming whether a program will successfully do all the jobs for which it has
been designed under the specified constraints. For testing a program, different sets of data are fed as
input to that program to test the different paths in the program logic.
Limitations of Flowcharts
Takes More Time to Draw
COMPUTER FUNDAMENTALS INTRODUCTION TO COMPUTERS
+88-01719-033364
Page 62 of 157
S M TALHA JUBAED
+88-01911-088706
Page 63 of 157
S M TALHA JUBAED
+88-01911-088706
Page 64 of 157
S M TALHA JUBAED
+88-01911-088706
Page 65 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://successnotes4u.blogspot.com/2012/02/machine-language-its-advantages.html
[2] http://successnotes4u.blogspot.com/2012/02/assembly-language-its-advantages-and.html
Page 66 of 157
S M TALHA JUBAED
+88-01911-088706
Page 67 of 157
S M TALHA JUBAED
+88-01911-088706
Page 68 of 157
S M TALHA JUBAED
+88-01911-088706
Page 69 of 157
S M TALHA JUBAED
+88-01911-088706
>
<
>=
<=
Description
Checks if the values of two operands are equal or
not. If yes, then the condition becomes true.
Checks if the values of two operands are equal or
not. If the values are not equal, then the condition
becomes true.
Checks if the value of left operand is greater than the
value of right operand. If yes, then the condition
becomes true.
Checks if the value of left operand is less than the
value of right operand. If yes, then the condition
becomes true.
Checks if the value of left operand is greater than or
equal to the value of right operand. If yes, then the
condition becomes true.
Checks if the value of left operand is less than or
equal to the value of right operand. If yes, then the
condition becomes true.
Example
(A == B) is not true.
(A != B) is true.
(A < B) is true.
(A <= B) is true.
Logical Operators
Following table shows all the logical operators supported by C language. Assume variable A holds 1
and variable B holds 0, then
Operator
&&
||
Description
Called Logical AND operator. If both the operands
are non-zero, then the condition becomes true.
Called Logical OR Operator. If any of the two
operands is non-zero, then the condition becomes
true.
Called Logical NOT Operator. It is used to reverse
the logical state of its operand. If a condition is true,
then Logical NOT operator will make it false.
Example
(A && B) is false.
(A || B) is true.
Question: What is Operator? Briefly describe about different Operators of C Programming Language.
Operator:
An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C
language is rich in built-in operators and provides the following types of operators
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Misc Operators
Arithmetic Operators
The following table shows all the arithmetic operators supported by the C language. Assume variable A
holds 10 and variable B holds 20 then
COMPUTER FUNDAMENTALS INTRODUCTION TO COMPUTERS
+88-01719-033364
Page 70 of 157
S M TALHA JUBAED
+88-01911-088706
Operator
+
*
/
%
++
--
Description
Adds two operands.
Subtracts second operand from the first.
Multiplies both operands.
Divides numerator by de-numerator.
Modulus Operator and remainder of after an integer
division.
Increment operator increases the integer value by
one.
Decrement operator decreases the integer value by
one.
Example
A + B = 30
A B = -10
A * B = 200
B/A=2
B%A=0
A++ = 11
A-- = 9
Relational Operators
The following table shows all the relational operators supported by C. Assume variable A holds 10 and
variable B holds 20 then
Operator
==
!=
>
<
>=
<=
Description
Checks if the values of two operands are equal or
not. If yes, then the condition becomes true.
Checks if the values of two operands are equal or
not. If the values are not equal, then the condition
becomes true.
Checks if the value of left operand is greater than the
value of right operand. If yes, then the condition
becomes true.
Checks if the value of left operand is less than the
value of right operand. If yes, then the condition
becomes true.
Checks if the value of left operand is greater than or
equal to the value of right operand. If yes, then the
condition becomes true.
Checks if the value of left operand is less than or
equal to the value of right operand. If yes, then the
condition becomes true.
Example
(A == B) is not true.
(A != B) is true.
(A < B) is true.
(A <= B) is true.
Logical Operators
Following table shows all the logical operators supported by C language. Assume variable A holds 1
and variable B holds 0, then
Operator
&&
||
Description
Called Logical AND operator. If both the operands
are non-zero, then the condition becomes true.
Called Logical OR Operator. If any of the two
operands is non-zero, then the condition becomes
true.
Called Logical NOT Operator. It is used to reverse
the logical state of its operand. If a condition is true,
then Logical NOT operator will make it false.
Example
(A && B) is false.
(A || B) is true.
Bitwise Operators
Page 71 of 157
S M TALHA JUBAED
+88-01911-088706
q
0
1
1
0
p&q p|q
0
0
0
1
1
1
0
1
p^q
0
1
0
1
>>
Description
Binary AND Operator copies a bit to the result if it
exists in both operands.
Binary OR Operator copies a bit if it exists in either
operand.
Binary XOR Operator copies the bit if it is set in one
operand but not both.
Binary Ones Complement Operator is unary and has
the effect of 'flipping' bits.
Binary Left Shift Operator. The left operands value is
moved left by the number of bits specified by the
right operand.
Binary Right Shift Operator. The left operands value
is moved right by the number of bits specified by the
right operand.
Example
(A & B) = 12, i.e., 0000 1100
(A | B) = 61, i.e., 0011 1101
(A ^ B) = 49, i.e., 0011 0001
(~A ) = -61, i.e,. 1100 0011 in 2's
complement form.
A << 2 = 240 i.e., 1111 0000
Assignment Operators
The following table lists the assignment operators supported by the C language
Operator
=
Description
Simple assignment operator. Assigns values from
right side operands to left side operand
Page 72 of 157
Example
C = A + B will assign the value of
A + B to C
S M TALHA JUBAED
+88-01911-088706
-=
*=
/=
%=
<<=
>>=
&=
^=
|=
C += A is equivalent to C = C + A
C -= A is equivalent to C = C - A
C *= A is equivalent to C = C * A
C /= A is equivalent to C = C / A
C %= A is equivalent to C = C %
A
C <<= 2 is same as C = C << 2
C >>= 2 is same as C = C >> 2
C &= 2 is same as C = C & 2
C ^= 2 is same as C = C ^ 2
C |= 2 is same as C = C | 2
Description
Returns the size of a variable.
&
*
?:
Pointer to a variable.
Conditional Expression.
Example
sizeof(a), where a is integer, will
return 4.
&a; returns the actual address of
the variable.
*a;
If Condition is true ? then value X
: otherwise value Y
Operators Precedence in C
Operator precedence determines the grouping of terms in an expression and decides how an
expression is evaluated. Certain operators have higher precedence than others; for example, the
multiplication operator has a higher precedence than the addition operator.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher precedence
than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the lowest
appear at the bottom. Within an expression, higher precedence operators will be evaluated first.
Category
Postfix
Unary
Multiplicative
Additive
Shift
Relational
Operator
() [] -> . ++ - + - ! ~ ++ - - (type)* & sizeof
*/%
+<< >>
< <= > >=
Page 73 of 157
Associativity
Left to right
Right to left
Left to right
Left to right
Left to right
Left to right
S M TALHA JUBAED
+88-01911-088706
== !=
&
^
|
&&
||
?:
= += -= *= /= %=>>= <<= &= ^= |=
,
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Right to left
Right to left
Left to right
Question: What do you mean by pseudo-code of a program? What are the advantages and Disadvantages
of Pseudo-Code? 5 October-2012
Pseudo-code of a program
Pseudocode is an informal high-level description of the operating principle of a computer
program or other algorithm. Pseudocode is a program analysis tool that is used for planning program
logic. "Pseudo" means imitation or false and "Code" refers to the instructions written in a programming
language. Pseudocode, therefore, is an imitation of actual computer instructions. These pseudo
instructions are phrases written in ordinary natural language (e.g., English, French, German, etc.).
Instead of using symbols to describe the logic steps of a program, as in flowcharting, pseudocode uses a
structure that resembles computer instructions. Because it emphasises the design of the program,
pseudocode is also called Program Design Language (PDL).
Pseudocode is made up of the following basic logic structures that have been proved to be sufficient for
writing any computer program :
1. Sequence
2. Selection (IF...THEN...ELSE or IF....THEN)
1. Iteration (DO...WHILE or REPEAT...UNTIL)
It uses the structural conventions of a programming language, but is intended for human reading rather
than machine reading. Pseudocode typically omits details that are essential for machine understanding
of the algorithm, such as variable declarations, system-specific code and some subroutines. The
programming language is augmented with natural language description details, where convenient, or
with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to
understand than conventional programming language code, and that it is an efficient and environmentindependent description of the key principles of an algorithm. It is commonly used in textbooks and
scientific publications that are documenting various algorithms, and also in planning of computer
program development, for sketching out the structure of the program before the actual coding takes
place.
No standard for pseudocode syntax exists, as a program in pseudocode is not an executable program.
Pseudocode resembles, but should not be confused with skeleton programs which can be compiled
without errors. Flowcharts, drakon-charts and Unified Modeling Language (UML) charts can be thought
of as a graphical alternative to pseudocode, but are more spacious on paper.
Advantages of Pseudocodes
Pseudocode has three main advantages:
(a) Converting a pseudocode to a programming language is much more easier as compared to
converting a flowchart or a decision table.
(b) As compared to a flowchart, it is easier to modify the pseudocode of a program logic when program
modifications are necessary.
(c) Writing of pseudocode involves much less time and effort than drawing an equivalent flowchart.
Pseudocode is easier to write than an actual programming language because it has only a few rules to
follow, allowing the programmer to concentrate on the logic of the program.
Page 74 of 157
S M TALHA JUBAED
+88-01911-088706
Page 75 of 157
S M TALHA JUBAED
+88-01911-088706
Page 76 of 157
S M TALHA JUBAED
+88-01911-088706
The figure below explains the working of break statement in all three type of loops.
Page 77 of 157
S M TALHA JUBAED
+88-01911-088706
/* C program to demonstrate the working of break statement by terminating a loop, if user inputs
negative number*/
# include <stdio.h>
int main(){
float num,average,sum;
int i,n;
printf("Maximum no. of inputs\n");
scanf("%d",&n);
for(i=1;i<=n;++i){
printf("Enter n%d: ",i);
scanf("%f",&num);
if(num<0.0)
break;
//for loop breaks if num<0.0
sum=sum+num;
}
average=sum/(i-1);
printf("Average=%.2f",average);
return 0;
}
Output
Maximum no. of inputs
4
Page 78 of 157
S M TALHA JUBAED
+88-01911-088706
For better understanding of how continue statements works in C programming. Analyze the figure
below which bypasses some code/s inside loops using continue statement.
Page 79 of 157
S M TALHA JUBAED
+88-01911-088706
Output
Enter num1:3
Enter num2:0
Enter num3:-5
Enter num4:2
product=-30
Reference:
[1] http://www.programiz.com/c-programming/c-break-continue-statement
Page 80 of 157
S M TALHA JUBAED
+88-01911-088706
Page 81 of 157
S M TALHA JUBAED
+88-01911-088706
Page 82 of 157
S M TALHA JUBAED
+88-01911-088706
Page 83 of 157
S M TALHA JUBAED
+88-01911-088706
START
Enter Roll #
& Name
Enter a Subject
Obtained Marks
Loop 10 times
Loop 10 times
Display a
Percentages Along
With Roll# &
Name
STOP
Page 84 of 157
S M TALHA JUBAED
+88-01911-088706
START
Enter a Roll#,
Name &marks
Loop 50 times
Loop 50 times
Calculate a Percentages of
Each Student
Loop 50 time
Display a
Percentages Along
With Roll# &
Name
STOP
Page 85 of 157
S M TALHA JUBAED
+88-01911-088706
START
Enter a
Name & age
If
age
>20
Yes
Process on data
Display name
&age
STOP
Page 86 of 157
S M TALHA JUBAED
+88-01911-088706
START
Enter a
Name & age
Youngest
Oldest
Check
which
student is
young
which is old
Process on data
& loop
Process on data
& loop
Display Young
name &age
Display Young
name &age
STOP
Page 87 of 157
S M TALHA JUBAED
+88-01911-088706
START
Enter scores
(0-100)
Yes Loop
If
scores
>90
No
Display total
marks
STOP
Page 88 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://www.rff.com/find-largest-number.htm
Page 89 of 157
S M TALHA JUBAED
+88-01911-088706
Page 90 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://www.rff.com/prime-numbers.htm
Page 91 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://www.rff.com/n_factorial_flowchart.htm
Page 92 of 157
S M TALHA JUBAED
+88-01911-088706
Reference:
[1] http://www.rff.com/fibonacci-numbers.htm
Page 93 of 157
S M TALHA JUBAED
+88-01911-088706
Page 94 of 157
S M TALHA JUBAED
+88-01911-088706
Symbol Name
(alias)
Process
Predefined
Process
(Subroutine)
Flow
Line
(Arrow,
Connector)
Decision
Connector
(Inspection)
Data
(I/O)
Symbol Description
Page 95 of 157
S M TALHA JUBAED
+88-01911-088706
Page 96 of 157
S M TALHA JUBAED
+88-01911-088706
Page 97 of 157
S M TALHA JUBAED
+88-01911-088706
Page 98 of 157
S M TALHA JUBAED
+88-01911-088706
Page 99 of 157
S M TALHA JUBAED
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Question: Draw the flowchart to read 50 number then find the average.
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Programming
Program-01: You have an array A of 100 elements. Write a program using any high level language of your
choice, which finds and displays the odd numbers of the array. April-2014
#include<stdio.h>
#include <iostream>
using namespace std;
int main(){
int number;
int min,max;
cout << "Enter the minimum range: ";
cin >> min;
cout << "Enter the maximum range: ";
cin >> max;
cout << "Odd numbers in given range are: ";
for(number = min;number <= max; number++)
if(number % 2 !=0)
cout << number<< " ";
return 0;
}
OUTPUT:
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
#include<stdio.h>
#include <iostream>
using namespace std;
int main(){
int number;
int min,max;
cout << "Enter the minimum range: ";
cin >> min;
cout << "Enter the maximum range: ";
cin >> max;
cout << "Odd numbers in given range are: ";
for(number = min;number <= max; number++)
if(number % 2 !=0)
cout << number<< " ";
printf("\nEven numbers in given range are: ");
for(number = min;number <= max; number++)
if(number % 2 ==0)
cout << number << " ";
return 0;
}
OUTPUT:
http://programmingknowledgeblog.blogspot.com/2013/04/c-code-to-print-all-odd-and-
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Similar Question: Write a program using C, C++ or FORTRAN which reads two integer numbers
from a keyboard and prints their sum to the computer console. 8 April-2005
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Reference:
[1] http://ecomputernotes.com/what-is-c/control-structures/add-numbers-until-a-negativeor-zero-is-encountered
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Reference:
[1] https://www.macs.hw.ac.uk/~pjbk/pathways/cpp1/node122.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output
Enter an positive integer: 20
Sum = 210
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Second Part:
Given Code Segment:
int i, j, k;
k=2;
j = 10;
i = 5;
while( ) {
printf(i=%d, j=%d and k=%d, i, j, k);
j=j-2;
}
Output:
i=5, j=10, k=2
i=5, j=8, k=2
i=5, j=6, k=2
i=5, j=4, k=2
i=5, j=2, k=2
Question: Write a program, using any high-level language, which asks the user to enter the radius of a
sphere, and then computes and displays the spheres area and volume where = 4 2 and =
4
3 . 8 October-2013
3
C program for area of a sphere
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Reference:
[1] http://www.sanfoundry.com/c-program-volume-surface-area-sphere/
[2] http://www.cquestions.com/2011/07/write-c-program-to-find-volume-and_2200.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
#include<stdio.h>
#include<math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(){
float r,l,w,h,a,b,c;
int n;
float perimeter;
//Perimeter of square
printf("Enter the size of any side square : ");
scanf("%f",&a);
perimeter = 4 * a;
printf("Perimeter of square is: %.3f",perimeter);
//Perimeter of rectangle
printf("\n\nEnter width and length of the rectangle : ");
scanf("%f%f",&w,&l);
perimeter = 2 * (w +l);
printf("Perimeter of rectangle is: %.3f",perimeter);
//Perimeter of triangle
printf("\n\nEnter the size of all sides of the triangle : ");
scanf("%f%f%f",&a,&b,&c);
perimeter = a + b + c;
printf("Perimeter of triangle is: %.3f",perimeter);
//Perimeter of circle
printf("\n\nEnter the radius of the circle : ");
COMPUTER FUNDAMENTALS INTRODUCTION TO COMPUTERS
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter the size of any side square: 4
Perimeter of square is: 16.000
Enter width and length of the rectangle: 4 8
Perimeter of rectangle is: 24.000
Enter the size of all sides of the triangle: 3 4 5
Perimeter of triangle is: 12.000
Enter the radius of the circle: 4
Perimeter of circle is: 25.133
Enter width, length and height of the cuboids: 5 10 15
Perimeter of cuboids is: 120.000
Enter any side of the cube: 4
Perimeter of cube is: 48.000
Enter any side of the rhombus: 4
Perimeter of rhombus is: 16.000
Enter size of any two consecutive side of parallelogram: 4 8
Perimeter of parallelogram is: 24.000
Enter any side of the equilateral triangle: 3
Perimeter of equilateral triangle is: 9.000
Enter the width and height of the right angled triangle: 5 12
Perimeter of right angled triangle is: 30.000
Enter the any side of the equilateral polygon: 5
Enter the total numbers of sides of equilateral polygon: 8
Perimeter of equilateral polygon is: 40.000
Enter the total number of sides in the regular polygon: 6
Enter the distance between any vertex and center of the regular polygon: 11
Perimeter of regular polygon is: 66.000
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Question: Write a program to find the largest value of given numbers using any programming language.
10 October-2011
Simple program of C find the largest number
#include<stdio.h>
int main(){
int n,num,i;
int big;
printf("Enter the values of n: ");
scanf("%d",&n);
printf("Number %d",1);
scanf("%d",&big);
for(i=2;i<=n;i++){
printf("Number %d: ",i);
scanf("%d",&num);
if(big<num)
big=num;
}
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample Output:
Enter the values of n:
Number 1: 12
Number 2: 32
Number 3: 35
Largest number is: 35
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter a number: 123
Sum of digits of number: 6
Code 2:
1. Sum of digits of a number in c using for loop
#include<stdio.h>
int main(){
int num,sum=0,r;
printf("Enter a number: ");
scanf("%d",&num);
for(;num!=0;num=num/10){
r=num%10;
sum=sum+r;
}
printf("Sum of digits of number: %d",sum);
return 0;
}
Sample output:
Enter a number: 567
Sum of digits of number: 18
Code 3:
1. Sum of digits in c using recursion
#include<stdio.h>
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter a number: 45
Sum of digits of number: 9
Reference:
[1] http://www.cquestions.com/2010/06/write-c-program-to-find-out-sum-of.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter any two integers: 5 10
Before swapping: a = 5, b=10
After swapping: a = 10, b=10
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
#include<stdio.h>
void swap(int *,int *);
int main(){
int a,b;
printf("Enter any two integers: ");
scanf("%d%d",&a,&b);
printf("Before swapping: a = %d, b=%d",a,b);
swap(&a,&b);
printf("\nAfter swapping: a = %d, b=%d",a,b);
return 0;
}
void swap(int *a,int *b){
int *temp;
temp = a;
*a=*b;
*b=*temp;
}
Sample output:
Enter any two integers: 3 6
Before swapping: a = 3, b=6
After swapping: a = 6, b=6
Reference:
[1] http://www.cquestions.com/2011/09/c-program-for-swapping-of-two-numbers.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter any number: 12
Reversed of number: 21
Code 2:
1. Reverse very large or big numbers beyond the range of long int
2. Reverse five digit number c program
Logic is we accept the number as string
#include<stdio.h>
#define MAX 1000
int main(){
char num[MAX];
int i=0,j,flag=0;
printf("Enter any positive integer: ");
scanf("%s",num);
while(num[i]){
if(num[i] < 48 || num[i] > 57){
printf("Invalid integer number");
return 0;
}
i++;
}
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
printf("Reverse: ");
for(j=i-1;j>=0;j--)
if(flag==0 && num[j] ==48){
}
else{
printf("%c",num[j]);
flag =1;
}
return 0;
Sample output:
Enter any positive integer: 234561000045645679001237800000000000
Reverse: 8732100976546540000165432
Code 3:
1. C program to reverse a number using for loop
2. How to find reverse of a number in c
3. Wap to reverse a number in c
#include<stdio.h>
int main(){
int num,r,reverse=0;
printf("Enter any number: ");
scanf("%d",&num);
for(;num!=0;num=num/10){
r=num%10;
reverse=reverse*10+r;
}
printf("Reversed of number: %d",reverse);
return 0;
}
Sample output:
Enter any number: 123
Reversed of number: 321
Code 4:
1. C program to reverse a number using recursion
#include<stdio.h>
int main(){
int num,reverse;
printf("Enter any number: ");
scanf("%d",&num);
reverse=rev(num);
printf("Reverse of number: %d",reverse);
return 0;
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter any number: 456
Reverse of number: 654
Reference:
[1] http://www.cquestions.com/2008/01/c-program-to-reverse-any-number.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter any two integers: 5 10
Sum of two integers: 15
Algorithm:
In c ~ is 1's complement operator. This is equivalent to:
~a = -b + 1
So, a - ~b -1
= a-(-b + 1) + 1
= a + b 1 + 1
= a + b
Reference:
[1] http://www.cquestions.com/2011/07/write-c-program-to-add-two-numbers.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample Output:
Enter any two integers: 5 4
Difference of two integers: 1
Reference:
[1] http://www.cquestions.com/2011/07/write-c-program-to-subtract-two-numbers.html
Question: Write a c program to find largest among three numbers using binary minus operator. 10
Marks
#include<stdio.h>
int main(){
int a,b,c;
printf("\nEnter 3 numbers: ");
scanf("%d %d %d",&a,&b,&c);
if(a-b>0 && a-c>0)
printf("\nGreatest is a :%d",a);
else
if(b-c>0)
printf("\nGreatest is b :%d",b);
else
printf("\nGreatest is c :%d",c);
return 0;
}
Reference:
[1] http://www.cquestions.com/2010/06/write-c-program-to-find-largest-among.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Sample output:
Enter a number: 123
Each digits of given number are: 1 2 3
Reference:
[1] http://www.cquestions.com/2011/09/split-number-into-digits-in-c.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
%d",count);
Sample output:
Enter a number: 23
Total digits is: 2
Code 2:
C code to count the total number of digit using for loop
#include<stdio.h>
int main(){
int num,count=0;
printf("Enter a number: ");
scanf("%d",&num);
for(;num!=0;num=num/10)
count++;
printf("Total digits is:
%d",count);
return 0;
}
Sample output:
Enter a number: 456
Total digits is: 3
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
%d",count);
}
int countDigits(int num){
static int count=0;
if(num!=0){
count++;
countDigits(num/10);
}
return count;
}
Sample output:
Enter a number: 1234567
Total digits is: 7
Reference:
[1] http://www.cquestions.com/2011/09/c-program-to-count-number-of-digits-in.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Reference:
[1] http://www.cquestions.com/2008/01/write-c-program-to-find-prime-factors.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Reference:
[1] http://letusprogrm.blogspot.com/2013/12/include-int-max-int-5-int-min-int-5-int.html
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
/* C program to check whether a year is leap year or not using if else statement.*/
#include <stdio.h>
int main(){
int year;
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0)
{
if( year%100 == 0) /* Checking for a century year */
{
if ( year%400 == 0)
printf("Yes ! %d is a leap year.", year);
else
printf("No ! %d is not a leap year.", year);
}
else
printf("Yes ! %d is a leap year.", year );
}
else
printf("No ! %d is not a leap year.", year);
return 0;
}
Output 2
Reference:
[1] http://www.programiz.com/c-programming/examples/leap-year
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output 1
Enter an integer you want to check: 25
25 is odd.
Output 2
Enter an integer you want to check: 12
12 is even.
Reference:
[1] http://www.programiz.com/c-programming/examples/even-odd
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output 1
Enter a number: 12.3
12.30 is positive.
Output 2
Enter a number: 0
You entered zero.
Reference:
[1] http://www.programiz.com/c-programming/examples/negative-positive-zero
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output
Enter an integer: 100
Sum = 5050
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output
Enter a positive integer: 29
29 is a prime number.
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output
Enter an integer: 12321
12321 is a palindrome.
Reference:
[1] http://www.programiz.com/c-programming/examples/palindrome-number
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output
Enter two numbers(intervals): 20
50
Prime numbers between 20 and 50 are: 23 29 31 37 41 43 47
Reference:
[1]
intervals
http://www.programiz.com/c-programming/examples/prime-number-
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706
Output
Enter the numbers of data: 6
1. Enter number: 45.3
2. Enter number: 67.5
3. Enter number: -45.6
4. Enter number: 20.34
5. Enter number: 33
6. Enter number: 45.6
Average = 27.69
Reference:
[1] http://www.programiz.com/c-programming/examples/average-arrays
Reference:
[1] http://www.sanfoundry.com/c-program-two-integers-equal/
S M TALHA JUBAED
+88-01719-033364
+88-01911-088706