Showing posts with label programming languages. Show all posts
Showing posts with label programming languages. Show all posts

Saturday, June 27, 2020

Scaffolding


  • Scaffolding, as used in computing, refers to one of two techniques: The first is a code generation technique related to database access in some model–view–controller frameworks; the second is a project generation technique supported by various tools. 


Code generation
Scaffolding is a technique supported by some model–view–controller frameworks, in which the programmer can specify how the application database may be used. The compiler or framework uses this specification, together with pre-defined code templates, to generate the final code that the application can use to create, read, update and delete database entries, effectively treating the templates as a "scaffold" on which to build a more powerful application.

Project generation
Complicated software projects often share certain conventions on project structure and requirements. For example, they often have separate folders for source code, binaries and code tests, as well as files containing license agreements, release notes and contact information
https://en.wikipedia.org/wiki/Scaffold_(programming)

Friday, May 8, 2020

Dynamic Programming


  • Dynamic programming is both a mathematical optimization method and a computer programming method.In both contexts it refers to simplifying a complicated problem by breaking it down into simpler sub-problems in a recursive manner. While some decision problems cannot be taken apart this way, decisions that span several points in time do often break apart recursively. Likewise, in computer science, if a problem can be solved optimally by breaking it into sub-problems and then recursively finding the optimal solutions to the sub-problems, then it is said to have optimal substructure.
If sub-problems can be nested recursively inside larger problems, so that dynamic programming methods are applicable, then there is a relation between the value of the larger problem and the values of the sub-problems.In the optimization literature this relationship is called the Bellman equation.

Mathematical optimization

In terms of mathematical optimization, dynamic programming usually refers to simplifying a decision by breaking it down into a sequence of decision steps over time.

Computer programming

There are two key attributes that a problem must have in order for dynamic programming to be applicable: optimal substructure and overlapping sub-problems.
If a problem can be solved by combining optimal solutions to non-overlapping sub-problems, the strategy is called "divide and conquer" instead.This is why merge sort and quick sort are not classified as dynamic programming problems.
Optimal substructure means that the solution to a given optimization problem can be obtained by the combination of optimal solutions to its sub-problems. Such optimal substructures are usually described by means of recursion.
Overlapping sub-problems means that the space of sub-problems must be small, that is, any recursive algorithm solving the problem should solve the same sub-problems over and over, rather than generating new sub-problems. For example, consider the recursive formulation for generating the Fibonacci series.Even though the total number of sub-problems is actually small (only 43 of them), we end up solving the same problems over and over if we adopt a naive recursive solution such as this. Dynamic programming takes account of this fact and solves each sub-problem only once.

This can be achieved in either of two ways:
Top-down approach: This is the direct fall-out of the recursive formulation of any problem. If the solution to any problem can be formulated recursively using the solution to its sub-problems, and if its sub-problems are overlapping, then one can easily memoize or store the solutions to the sub-problems in a table. Whenever we attempt to solve a new sub-problem, we first check the table to see if it is already solved. If a solution has been recorded, we can use it directly, otherwise we solve the sub-problem and add its solution to the table.


Bottom-up approach: Once we formulate the solution to a problem recursively as in terms of its sub-problems, we can try reformulating the problem in a bottom-up fashion: try solving the sub-problems first and use their solutions to build-on and arrive at solutions to bigger sub-problems. This is also usually done in a tabular form by iteratively generating solutions to bigger and bigger sub-problems by using the solutions to small sub-problems. 


https://en.wikipedia.org/wiki/Dynamic_programming


https://en.wikipedia.org/wiki/Memoization

  • That's what Dynamic Programming is about. To always remember answers to the sub-problems you've already solved.
https://www.hackerearth.com/practice/algorithms/dynamic-programming/introduction-to-dynamic-programming-1/tutorial/

  • Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems, so that we do not have to re-compute them when needed later. This simple optimization reduces time complexities from exponential to polynomial. For example, if we write simple recursive solution for Fibonacci Numbers, we get exponential time complexity and if we optimize it by storing solutions of subproblems, time complexity reduces to linear.
https://www.geeksforgeeks.org/dynamic-programming/

  • Dynamic programming approach is similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub-problems. But unlike, divide and conquer, these sub-problems are not solved independently. Rather, results of these smaller sub-problems are remembered and used for similar or overlapping sub-problems.
Dynamic programming is used where we have problems, which can be divided into similar sub-problems, so that their results can be re-used. 
  • The problem should be able to be divided into smaller overlapping sub-problem.
  • An optimum solution can be achieved by using an optimum solution of smaller sub-problems.
  • Dynamic algorithms use Memoization.
In contrast to greedy algorithms, where local optimization is addressed, dynamic algorithms are motivated for an overall optimization of the problem.
In contrast to divide and conquer algorithms, where solutions are combined to achieve an overall solution, dynamic algorithms use the output of a smaller sub-problem and then try to optimize a bigger sub-problem. Dynamic algorithms use Memoization to remember the output of already solved sub-problems.

The following computer problems can be solved using dynamic programming approach −
  • Fibonacci number series
  • Knapsack problem
  • Tower of Hanoi
  • All pair shortest path by Floyd-Warshall
  • Shortest path by Dijkstra
  • Project scheduling
https://www.tutorialspoint.com/data_structures_algorithms/dynamic_programming.htm

There are 3 main parts to divide and conquer:
  1. Divide the problem into smaller sub-problems of the same type.
  2. Conquer - solve the sub-problems recursively.
  3. Combine - Combine all the sub-problems to create a solution to the original problem.
https://skerritt.blog/dynamic-programming/

Dynamic Programming Defined

Dynamic programming amounts to breaking down an optimization problem into simpler sub-problems, and storing the solution to each sub-problem so that each sub-problem is only solved once.
https://www.freecodecamp.org/news/demystifying-dynamic-programming-3efafb8d4296/

Monday, April 20, 2020

fourth-generation language


  • fourth-generation language

A non-procedural programming language that requires less coding than lower-level languages. Command-line languages that come with operating systems and database management systems (DBMSs) are fourth-generation languages (4GLs), as are query languages and report writers. Any language with English-like commands that does not require traditional input-process-output logic falls into this category.

First-, Second- and Third-Generation Languages
First-generation languages are binary machine languages. Second-generation languages are machine-dependent assembly languages, and third-generation languages (3GLs) are high-level programming languages, such as FORTRAN, COBOL, BASIC, Pascal, C/C++ and Java.

https://www.pcmag.com/encyclopedia/term/fourth-generation-language


Tuesday, January 5, 2016

JOVIAL


  • JOVIAL is a high-level computer programming language similar to ALGOL, but specialized for the development of embedded systems (specialized computer systems designed to perform one or a few dedicated functions, usually embedded as part of a complete device including mechanical parts).
https://en.wikipedia.org/wiki/JOVIAL

Wednesday, March 6, 2013

Memory safety



  • Memory safety 

Memory safety is a concern in software development that aims to avoid software bugs that cause security vulnerabilities dealing with random-access memory (RAM) access, such as buffer overflows and dangling pointers.
Computer languages such as C and C++ that support arbitrary pointer arithmetic, casting, and deallocation are typically not memory safe

Types of memory errors
    Buffer overflow - Out-of bound writes can corrupt the content of adjacent objects, or internal data like bookkeeping information for the heap or return addresses.
    Dynamic memory errors - Incorrect management of dynamic memory and pointers:
        Dangling pointer - A pointer storing the address of an object that has been deleted.
        Double frees - Repeated call to free though the object has been already freed can cause freelist-based allocators to fail.
        Invalid Free - Passing an invalid address to free can corrupt the heap. Or sometimes will lead to an undefined behavior.
        Null pointer accesses will cause an exception or program termination in most environments, but can cause corruption in operating system kernels or systems without memory protection, or when use of the null pointer involves a large or negative offset.
    Uninitialized variables - A variable that has not been assigned a value is used. It may contain an undesired or, in some languages, a corrupt value.
        Wild pointers arise when a pointer is used prior to initialization to some known state. They show the same erratic behaviour as dangling pointers, though they are less likely to stay undetected.
    Out of memory errors:
        Stack overflow - Occurs when a program runs out of stack space, typically because of too deep recursion.
        Allocation failures - The program tries to use more memory than the amount available. In some languages, this condition must be checked for manually after each allocation.

Buffer overflow
A buffer is a temporary data storage area. Buffer overflow is the most common way for an attacker outside the system to gain unauthorized access to the target system. A buffer overflow occurs when a program tries to store more data in a buffer than it was intended to hold. Since buffers are created to contain a finite amount of data, the extra information can overflow into adjacent buffers, corrupting or overwriting the valid data held in them.It allows attacker to interfere into the existing process code. Attacker uses buffer or stack overflow to do following,

    Overflow the input field, command line space or input buffer.
    Overwrite the current return address on the stack with the address of the attacking code.
    write a simple code that attacker wishes to execute.

http://en.wikipedia.org/wiki/Memory_safety

Type safety

  • Type safety

In computer science, type safety is the extent to which a programming language discourages or prevents type errors.
A type error is erroneous or undesirable program behaviour caused by a discrepancy between differing data types for the program's constants, variables, and methods (functions), e.g., treating an integer (int) as a floating-point number (float).
some languages have type-safe facilities that can be circumvented by programmers who adopt practices that exhibit poor type safety

Type enforcement can be static, catching potential errors at compile time, or dynamic, associating type information with values at run-time and consulting them as needed to detect imminent errors, or a combination of both.

Type safety is closely linked to memory safety, a restriction on the ability to copy arbitrary bit patterns from one memory location to another. For instance, in an implementation of a language that has some type t, such that some sequence of bits (of the appropriate length) does not represent a legitimate member of t, if that language allows data to be copied into a variable of type t, then it is not type-safe because such an operation might assign a non-t value to that variable.

Conversely, if the language is type-unsafe to the extent of allowing an arbitrary integer to be used as a pointer, then it is clearly not memory-safe.

Type-safe code accesses only the memory locations it is authorized to access
(For this discussion, type safety specifically refers to memory type safety and should not be confused with type safety in a broader respect.)
For example, type-safe code cannot read values from another object's private fields.


Type safety is ultimately aimed at excluding other problems
Prevention of illegal operations. For example, we can identify an expression 3 / "Hello, World" as invalid, because the rules of arithmetic do not specify how to divide an integer by a string.
Memory safety
    Wild pointers can arise when a pointer to one type object is treated as a pointer to another type. For instance, the size of an object depends on the type, so if a pointer is incremented under the wrong credentials, it will end up pointing at some random area of memory.
Buffer overflow - Out-of bound writes can corrupt the contents of objects already present on the heap. This can occur when a larger object of one type is crudely copied into smaller object of another type.
Logic errors originating in the semantics of different types. For instance, inches and millimeters may both be stored as integers, but should not be substituted for each other or added. A type system can enforce two different types of integer for them.


#include <iostream>
using namespace std;

int main()
{
    int ival = 5;                   // A four-byte integer (on most processors)
    void *pval = &ival;             // Store the address of ival in an untyped pointer
    double dval = *((double*)pval); // Convert it to a double pointer and get the value at that address
    cout << dval << endl;           // Output the double (this will be garbage and not 5!)
    return 0;
}

/*
Even though pval does contain the correct address of ival,
when pval is cast from a void pointer to a double pointer the resulting double value is not 5,
but an undefined garbage value. On the machine code level,
this program has explicitly prevented the processor from performing the correct conversion from a four-byte integer to an eight-byte floating-point value.
When the program is run it will output a garbage floating-point value and possibly raise a memory exception.
Thus, C++ (and C) allow type-unsafe code.
*/

http://en.wikipedia.org/wiki/Type_safety





  • Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable.


Some simple examples:
// Fails, Trying to put an integer in a string
String one = 1;
// Also fails.
int foo = "bar";


This also applies to method arguments, since you are passing explicit types to them:
int AddTwoNumbers(int a, int b)
{
    return a + b;
}

If I tried to call that using: The compiler would throw an error, because I am passing a string ("5"), and it is expecting an integer.
int Sum = AddTwoNumbers(5, "5");



In a loosely typed language, such as javascript
function AddTwoNumbers(a, b)
{
    return a + b;
}
Sum = AddTwoNumbers(5, "5");
Javascript automaticly converts the 5 to a string, and returns "55".
This is due to javascript using the + sign for string concatenation
To make it type-aware, you would need to do something like:

function AddTwoNumbers(a, b)
{
    return Number(a) + Number(b);
}

Or, possibly:

function AddOnlyTwoNumbers(a, b)
{
    if (isNaN(a) || isNaN(b))
        return false;
    return Number(a) + Number(b);
}


http://stackoverflow.com/questions/260626/what-is-type-safe


why does array index start from zero?



  • why does array index start from zero?

To use a data item, you must calculate its correct address


Why do indexes of arrays start with zero?
The first location of an array is addressed by the pointer to the array.
Subsequent locations in the array are indicated by an offset from that pointer.
http://www.linkedin.com/groupItem?view=&gid=70526&type=member&item=218956807&commentID=123192360&report.success=8ULbKyXO6NDvmoK7o030UNOYGZKrvdhBhypZ_w8EpQrrQI-BBjkmxwkEOwBjLE28YyDIxcyEO7_TA_giuRN#commentID_123192360



  • Here's some C code to explain the offsets a little better:

Code:

int array[3];

int* parray = &array;

int val0 = *(parray + 0);   // 1st element (note the +0 is not required)
int val1 = *(parray + 1);   // 2nd element
int val2 = *(parray + 2);   // 3rd element

http://ubuntuforums.org/showthread.php?t=1275797


  • Zero-based numbering

Advantages
One advantage of this convention is in the use of modular arithmetic as implemented in modern computers. Usually, the modulo function maps any integer modulo N to one of the numbers 0, 1, 2, ..., N - 1, where N = 1. Because of this, many formulas in algorithms (such as that for calculating hash table indices) can be elegantly expressed in code using the modulo operation when array indices start at zero.

A second advantage of zero-based array indexes is that this can improve efficiency under certain circumstances. To illustrate, suppose a is the memory address of the first element of an array, and i is the index of the desired element. In this fairly typical scenario, it is quite common to want the address of the desired element. If the index numbers count from 1, the desired address is computed by this expression:

    a + s × (i - 1)

where s is the size of each element. In contrast, if the index numbers count from 0, the expression becomes this:

    a + s × i

This simpler expression can be more efficient to compute in certain situations.

A third advantage is that ranges are more elegantly expressed as the half-open interval, [0,n), as opposed to the closed interval, [1,n], because empty ranges often occur as input to algorithms (which would be tricky to express with the closed interval without resorting to obtuse conventions like [1,0])

http://en.wikipedia.org/wiki/Zero-based_numbering




  • It starts at 0 because the index value tells the computer how far it needs to move away from the starting point in the array.

if you use an array (without giving an index number in brackets), you are really only referring to the memory address of the starting point of the array
When you reference a specific value in the array, you are telling the programming language to start at the memory address of the beginning of the array and then move up the memory address as needed
lets say a program allocates space in the memory between address numbers 1024 and 2048 and it starts at 1024 and each item in the array is 8 bytes long
arrayName[0] is the same as telling it to look at the data stored at the memory address of (1024 + (0 * 8)), or 1024
If you want the value stored at arrayName[1], then it looks at the value held at (1024 + (1*8)), which is 1032
If you wanted the value held at arrayName[10], then it would look at the data stored in the memory address of 1024 + (10 * 8), which is 1104.
http://answers.yahoo.com/question/index?qid=20090528223815AACZDDY



  • The discussion over why the array index should start at zero is not a trivial one and relates to interesting concepts from computer science. 

First of all, it has strong relation to language design. For example in C, the name of an array is essentially a pointer, a reference to a memory location, and so the expression array[n] refers to a memory location n-elements away from the starting element.
This means that the index is used as an offset.
The first element of the array is exactly contained in the memory location that array refers (0 elements away), so it should be denoted as array[0]
http://developeronline.blogspot.com/2008/04/why-array-index-should-start-from-0.html

Tuesday, February 12, 2013

High Order Language



  • High Order Language (HOL)


Higher-order programming
Higher-order programming is a style of computer programming that uses functions as values.
It is usually instantiated with, or borrowed from, models of computation such as lambda calculus which make heavy use of higher-order functions.
http://en.wikipedia.org/wiki/Higher-order_programming


  • Higher Order Programming Is Easy!

If you have ever passed a function or method as a parameter to another function or method, then you have done higher order programming.
If you have ever used a function pointer in C or a delegate in C# or some kind of callback mechanism, then you have done higher order programming.
http://www.programmersheaven.com/user/pheaven/blog/133-Higher-Order-Programming-Is-Easy/

Monday, August 20, 2012

What is the difference between procedural and object-oriented programs?

  • What is the difference between procedural and object-oriented programs? 

a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code.
b) In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.

http://www.techinterviews.com/master-list-of-java-interview-questions

Friday, March 30, 2012

Operator Precedence And Associativity


  • Operator Precedence And Associativity

http://www.youtube.com/watch?v=n_eDAzzgzkA



Two characteristics of operators determine how they will group with operands:
precedence Precedence is the priority for grouping different types of operators with their operands.
associativity Associativity is the left-to-right or right-to-left order for grouping operands to operators that have the same precedence.

For example, in the following statements, the value of 5 is assigned to both a and b because of the right-to-left associativity of the = operator. The value of c is assigned to b first, and then the value of b is assigned to a.

b = 9;
c = 5;
a = b = c;

the * and / operations are performed before the + because of precedence. Further, b is multiplied by c before it is divided by d because of associativity.

a + b * c / d

http://northstar-www.dartmouth.edu/doc/ibmcxx/en_US/doc/language/concepts/cuexppre.htm




  • Operator Precedence in Java

For example, multiplication and division have a higher precedence than addition and subtraction. Precedence rules can be overridden by explicit parentheses

Precedence Order. When two operators share an operand the operator with the higher precedence goes first. For example, 1 + 2 * 3 is treated as 1 + (2 * 3), whereas 1 * 2 + 3 is treated as (1 * 2) + 3 since multiplication has a higher precedence than addition.

Associativity. When two operators with the same precendence the expression is evaluated according to its associativity
For example x = y = z = 17 is treated as x = (y = (z = 17)), leaving all three variables with the value 17, since the = operator has right-to-left associativty
 72 / 2 / 3 is treated as (72 / 2) / 3 since the / operator has left-to-right associativity.

What is the result of the following code fragment? Explain.

System.out.println("1 + 2 = " + 1 + 2);
 1 + 2 = 12 and 1 + 2 = 3, respectively. If either (or both) of the operands of the + operator is a string, the other is automatically cast to a string. String concatenation and addition have the same precedence. Since they are left-associative, the operators are evaluated left-to-right.

System.out.println("1 + 2 = " + (1 + 2));
  The parentheses in the second statement ensures that the second + operator performs addition instead of string concatenation
 
 
What does the following code fragment print?
System.out.println(1 + 2 + "abc");
System.out.println("abc" + 1 + 2);
Answer: 3abc and abc12, respectively. The + operator is left associative, whether it is string concatenation or arithmetic plus.

http://introcs.cs.princeton.edu/java/11precedence/



  • Operator Precedence and Associativity

Operator precedence is why the expression 5 + 3 * 2 is calculated as 5 + (3 * 2), giving 11, and not as (5 + 3) * 2, giving 16.
We say that the multiplication operator (*) has higher "precedence" or "priority" than the addition operator (+), so the multiplication must be performed first.

Operator associativity is why the expression 8 - 3 - 2 is calculated as (8 - 3) - 2, giving 3, and and not as 8 - (3 - 2), giving 7.
We say that the subtraction operator (-) is "left associative", so the left subtraction must be performed first. When we can't decide by operator precedence alone in which order to calculate an expression, we must use associativity.


Since the operators + and - have the same precedence, and are left-associative, the following expressions are all equivalent:
x + 3 - y + 5
(x + 3) - y + 5
((x + 3) - y) + 5
((x + 3) - y + 5)

Since the operators =, += and -= have the same precedence, and are right-associative, the following expressions are all equivalent:
x = y += z -= 4
x = y += (z -= 4)
x = (y += (z -= 4))
(x = y += (z -= 4))


http://docs.roxen.com/pike/7.0/tutorial/expressions/operator_tables.xml





  • Operator associativity

In programming languages and mathematical notation, the associativity (or fixity) of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses.

The choice of which operations to apply the operand to, is determined by the "associativity" of the operators. Operators may be left-associative (meaning the operations are grouped from the left), right-associative (meaning the operations are grouped from the right) or non-associative (meaning there is no defined grouping).

Consider the expression a ~ b ~ c.
If the operator ~ has left associativity, this expression would be interpreted as (a ~ b) ~ c and evaluated left-to-right
If the operator has right associativity, the expression would be interpreted as a ~ (b ~ c) and evaluated right-to-lef

Many programming language manuals provide a table of operator precedence and associativity

Associativity is only needed when the operators in an expression have the same precedence.
Usually + and - have the same precedence.

Consider the expression 7 - 4 + 2.
The result could be  (7 - 4) + 2 = 5
result corresponds to the case when + and - are left-associative

or 7 - (4 + 2) = 1.
+ and - are right-associative.


Usually the addition, subtraction, multiplication, and division operators are left-associative, while the exponentiation, assignment and conditional operators are right-associative.

To prevent cases where operands would be associated with two operators, or no operator at all, operators with the same precedence must have the same associativity.

A detailed example
Consider the expression 5^4^3^2. A parser reading the tokens from left to right would apply the associativity rule to a branch, because of the right-associativity of ^, in the following way:

Term 5 is read.
Nonterminal ^ is read. Node: "5^".
Term 4 is read. Node: "5^4".
Nonterminal ^ is read, triggering the right-associativity rule. Associativity decides node: "5^(4^".
Term 3 is read. Node: "5^(4^3".
Nonterminal ^ is read, triggering the re-application of the right-associativity rule. Node "5^(4^(3^".
Term 2 is read. Node "5^(4^(3^2".
No tokens to read. Apply associativity to produce parse tree "5^(4^(3^2))".

A left-associative evaluation would have resulted in the parse tree ((5^4)^3)^2


http://en.wikipedia.org/wiki/Operator_associativity

Lexical Analysis


  • Lexical Analysis

http://www.youtube.com/watch?v=B-nkdR4H530
http://www.youtube.com/watch?v=_1o9z4XIyx4




  • Lexical analysis

In computer science, lexical analysis is the process of converting a sequence of characters into a sequence of tokens
A program or function which performs lexical analysis is called a lexical analyzer, lexer, or scanner.
A lexer often exists as a single function which is called by a parser or another function.

http://en.wikipedia.org/wiki/Lexical_analysis



  • compiler phases





  • Lexical Analysis


A scanner groups input characters into tokens. For example, if the input is

x = x*(b+1);
then the scanner generates the following sequence of tokens
id(x)
=
id(x)
*
(
id(b)
+
num(1)
)
;

A typical scanner:

recognizes the keywords of the language (these are the reserved words that have a special meaning in the language, such as the word class in Java);
recognizes special characters, such as ( and ), or groups of special characters, such as := and ==;
recognizes identifiers, integers, reals, decimals, strings, etc;
ignores whitespaces (tabs and blanks) and comments;
recognizes and processes special directives (such as the #include "file" directive in C) and macros.


http://lambda.uta.edu/cse5317/notes/node6.html




Saturday, March 24, 2012

sinav sorulari-3







http://w3.gazi.edu.tr/web/akcayol/files/JavaOrnekVize.pdf

sinav sorulari-2












http://w3.gazi.edu.tr/web/akcayol/files/JavaOrnekVize.pdf

sinav sorulari-1

Örnek 1.2.1 : 1'den 100'e kadar olan sayıların toplamını veren algoritma.
1. Toplam T, sayılar da i diye çağırılsın.
2. Başlangıçta T'nin değeri 0 ve i'nin değeri 1 olsun.
3. i'nin deÄŸerini T'ye ekle.
4. i'nin değerini 1 arttır.
5. Eğer i'nin değeri 100'den büyük değil ise 3. adıma git.
6. T'nin deÄŸerini yaz.


Aynı algoritmayı aşağıdaki gibi yazabiliriz.
1. T=0 ve i=0
2. i'nin deÄŸerini T'ye ekle.
3. i'yi 1 arttır.
4. i<101 ise 2.adıma git.
5. T'nin deÄŸerini yaz.


Örnek 1.2.3 : İki tamsayının çarpma işlemini sadece toplama işlemi kullanarak gerçekleyin.
Girdi : iki tamsayı
Çıktı : sayıların çarpımı
1. a ve b sayılarını oku
2. c =0
3. b>0 olduğu sürece tekrarla
.3.1. c=c + a
3.2. b = b-1
4. c deÄŸerini yaz ve dur


Örnek 1.2.4 : Bir tamsayının faktoriyelini hesaplayınız.
Girdi : Bir tamsayı
Çıktı : sayının faktoriyel
İlgili formul: Faktoriyel(n)=1*2*...*n
1. n deÄŸerini oku
2. F=1
3. n >1 olduğu sürece tekrarla
.3.1. F=F*n
3.2. n= n-1
4. F deÄŸerini yaz


Örnek 1.2.5 : İki tamsayının bölme işlemini sadece çıkarma işlemi kullanarak gerçekleyin. Bölüm ve kalanın ne olduğu bulunacak.
1. a ve b deÄŸerlerini oku
2. m=0
3. a>=b olduğu sürece tekrarla
3.1 a=a-b
3.2 m = m + 1
4. kalan a ve bölüm m 'yi yaz



Kaynak:
http://www.izafet.com/c-ve-c/93459-c-dili-kullanarak-bilgisayar-programlama.html#ixzz1q2jZw7WZ


Bilgisayar belle inde bulunan n x n boyutlar ndaki bir A matrisinin
transpozesini (devri ini) al p (B=AT), bunu form üzerinde matris format nda
yazd ran bir program yaz n z.

For i=1 To n
For j=1 To n
B(i,j)=A(j,i)
Next i
Next j
For i=1 To n
For j=1 To n
Print B(i,j),
Next i
Print
Next j


“notlar.txt” isimli dosyada 1. s n f ö rencilerinin Bilgisayar Programlama
dersine ait numara, ad-soyad ve 1.vize not bilgileri bulunmaktad r. Bu dosyay
kullanarak, bu ders için minimum, maksimum ve ortalama notu hesaplay p,
Picture1 nesnesine yazd ran program olu
turunuz

N=100 ‘Ö renci say s
ReDim V1(N)
For i=1 To N
Input #1, no, ad, V1(i)
Toplam=Toplam+V1(i)
Next i
Close #1
Ort=Toplam/N


Max=V1(1)
Min=V1(1)
For i=1 to N
If V1(i)>Max Then Max=V1(i)
If V1(i)
main()
{
int i,sayi,ek=100,eb=-100,ta=0, cifta=0;
double tek=0.0;
for(i=0; i<5; i++)
{
scanf("%d",&sayi);
if (sayi>eb) eb=sayi;
if (sayi
void dca(int en,int boy, int *cevre, int *alan)
{
*cevre=2*en+2*boy;
*alan=en*boy;
}
int main()
{
int en,boy,C,A;
printf ("Dikdörtgene ait en ve boyu girin :");
scanf("%d %d",&en,&boy);
dca(en,boy,&C,&A);
printf("Dikdörtgenin çevresi=%3d \n Alanı=%3d",C,A);
return 0;
}






13. Ogrenci isimli sınıfta, parametre olarak dışarıdan String ve boolean türünde değişken alan sadece bir
constructor tanımlanmıştır. Bu sınıftan bir nesne yapmak istiyoruz. Aşağıdaki seçeneklerden hangisi
doÄŸrudur? [5 puan]
a. Ogrenci = new Ogrenci();
b. Ogr = Ogrenci(“java”, “true”);
c. Ogrenci ogr = new Ogrenci(“tobb”, false);
d. Ogrenci ogr = new Ogrenci(“true”);
e. Ogrenci ogr = Ogrenci(“tobb”, true);



http://w3.gazi.edu.tr/web/akcayol/files/JavaOrnekVize.pdf