Declarations inside a function is called local declaration
How do you write multiplication table program in php?
// example of 1..12x12 table
for($i = 1; $i <= 12; $i++)
{
for($j = 1; $j <= 12; $j++)
{
print ($i * $j) ." ";
}
print "\n";
}
What is the purpose of type declarations in c?
A type declaration introduces a user-defined type. The new type may be an alias, a structure, a union or an enumeration.
Aliases are typically used to reduce verbosity:
typedef unsigned long long UINT;
Here we can use the UINT alias wherever we'd normally use an unsigned long long. The compiler will treat the UINT type just as it would an unsigned long long. We can also use macros to achieve the same thing however a macro is not type safe.
Data structures allow us to create aggregate data types:
typedef struct Data { int x; double y; char* z; };
Unlike an array where all elements must be of the same type, data structure members may be any type (both built-in and user-defined) and of any length (in bytes). Each member has a name whereas array elements are accessed using zero-based subscripts. The length of a data structure is the sum of its member lengths plus any padding bytes for alignment purposes. For instance, pointers are typically aligned on word boundaries.
In the above example, the full name of the data type is struct Data. Repeating the struct keyword every time we want to use this data type can quickly become tiresome:
struct Data a[100];
struct Data* b;
struct Data c;
Fortunately, we can append an alias to reduce the verbosity:
typedef struct Data { int x; double y; char* z; } data;
Note that the actual type is still struct Data. However, we can now use the alias data in our code:
data a[100];
data* b;
data c;
Unions allow us to optimise memory consumption:
typedef union Stuff { char c; int i; long double d; } stuff;
Unlike a structure where each member is allocated separately, union members are allocated to the same address. The length of a union is equal to the length of the largest member. Unions are useful when we have two or more variables of different types but we only require one of them at any given time. The onus is on the programmer to keep track of which member is the active member.
A common error with new programmers is to use a union as an unsafe type cast. This is particularly bad when the cast is to a pointer type:
typedef union Stuff { int i; int* p; } stuff;
int* cheat (int x) {
stuff s;
s.i = x; // assign the value of x to s.i
return s.p; // "cast" x to a memory address (to int)
}
This function has undefined behaviour. Firstly, the code assumes that an int is the same length as a pointer to int. That may well be the case on some systems but certainly not for all systems. On a 64-bit system an int might be 4 bytes long, but a pointer may well be 8 bytes long. Under those circumstances, the integer value cannot possibly cover the entire address space. Worse, when we assign x to s.i, only the low-order bytes of s.p will be overwritten. The high-order bytes will be whatever value happens to reside in that memory at the time. The returned address could be pointing literally anywhere, but almost certainly not where you intended to be pointing. Even if sizeof (int) and sizeof (int*) are the same length, the code is still unsafe because it would be unreasonable to expect an integer to be allocated to an odd address and there's a 50% chance x is an odd value. Worse, integers are typically aligned on 4-byte boundaries and there's a 75% chance x is not a multiple of 4. And that's before we consider whether the address we return actually belongs to our program. In short, don't use unsafe casts!
An enumeration is simply a group of named constants.
enum e {m1, m2, m3, m4};
By default, members are enumerated in the order they are declared, starting at 0, incrementing by 1 for each subsequent member. However, we can assign any value to any member and restart the enumeration from that point onward. We can even assign the same value to more than one member.
Assuming the default values (m1=0, m2=1, m3=2 and m4=3), we can use the members just as we would any other constant:
void f (e data) {
if (data == m1) {
data = 20;
}
}
In the above example, although the data argument is an e type, we can assign it any valid integral value (20 is not defined by the e type). Typically we would want to restrict values to just those that we defined. For that we need to typedef the enumeration (with an alias):
typedef enum t {m1, m2, m3, m4} e;
void f (e data) {
if (data == m1) {
data = 20; // ERROR: 20 is not an e type
}
}
Enumerations are implicitly int. However, we can also specify any integral type as appropriate:
typedef enum t : char {m1, m2, m3, m4} e;
Explain with an example first come first serve scheduling algorithm?
By far the simplest CPU-scheduling algorithm is the first-come, first-served (FCFS) scheduling algorithm. With this scheme, the process that requests the CPU first is allocated the CPU first. The implementation of the FCFS policy is easily managed with a FIFO queue. When a process enters the ready queue, its PCB is linked onto the tail of the queue. When the CPU is free, it is allocated to the process at the head of the queue. The running process is then removed from the queue. The code for FCFS scheduling is simple to write and understand. The average waiting time under the FCFS policy, however, is often quite long. Consider the following set of processes that arrive at time 0, with the length of the CPU-burst time given in milliseconds:
What computer directly recognizes is plain machine code in over words sequence of 0 and 1, which in programming field mostly is displayed in HEX (base 16) system.
Sequence or bits: 10110000 00101001 (HEX: B0 29) in x86 architecture is understood as moving value 0x29 to AL register. In assembly language it would look like:
MOV AL, 0x29
Where 0x29 is 41 in decimal.
But the first generation of languages was Assembler (Or just "A", later followed by "B" (used for writing Unix system), "C" (now one of the widely used), now we have "D" language (mix of C++/JAVA/C#) coming).
To summarize, computer understand sequence of bits, while first generation of programming languages (low-level programming) was Assembler.
Object Oriented Programming (OOP) is the implementation (programming) of Object Oriented Design (OOD). The two usually go together, in in OOD/OOP. OOD is a concept where the design of a solution to a problem revolves around the objects it manipulates, specifically, standardizing the way we think about the attributes (data) and methods (operations) available in an object. While C++ is particularly well suited to OOP, the OOP paradigm can (and should) be extended to cover everything that a program manipulates, even to the extent of simple scalar variables such as an integer. This philosophy is based on some of the definitions of a "object", i.e. that is has storage, the contents of that storage has meaning, and that there are certain operations that can be performed on that storage using a defined interface. Using this concept, even an assembly programming language can be considered to be an Object Oriented Programming Language (OOPL)! What makes C++ and other OOPL's unique are the added concepts of inheritance, polymorphism, and data encapsulation, to name just three. Inheritance is the concept that an object can be declared/defined, and then a child object can inherit the parent object's design and extend it to include other, more specific, functionality. For example, you could design an object (we call them classes) that represents a person. The person class could describe a person's name, address, and social security number. The type of functions (we call them methods) that you could perform on a person could be to set or get their name, address, and social security number. You could then design a class that represents an employee. It could use class person as a base class, and then extend that implementation to include things such as work location, job title, and salary. Class employee has all of the capabilities of class person, but you do not have to write a single line of code for that implementation - you just write the code for the employee extension. Polymorphism is the concept that you can have pointers to various classes, and invoke a same named method, such as "print()", and the code selected will be the code for the type of object to which the pointer refers to. For example, person.print() would behave different than employee.print(). While this might seem trite, it becomes important when you have pointers that can refer to multiple types of related classes, and you want to virtualize the interface to classes pointed to by those pointers at run time, instead of at compile time. Data Encapsulation is, perhaps, one of the most important aspects of OOP/OOD. You design a class, such as person. Inside that class, lets say you define the person's name as an array of characters, say of length 25. You hide that attribute from any derived classes, such as employee, and force access to person.name though a method such as person::getName(). Everything is fine until one day, when you get a person with a 27 character name. You refactor the class person. You could make the array be 64 characters but, instead, you make it a pointer to a dynamically sized array. If you designed the interface person::getName() correctly, then the derived class employee does not need to change, you can relink everything and all is well. This capability can not be overestimated. Prior to OOD/OOP, there was a tendency for programmers to write code that used global variables, variables with scope throughout the program. As the program evolves, functions use those variables in ways that depend on the implementation. One day, you change the implementation, and now you need to go on a "hunt and destroy" mission to find all references to that variable. You might miss some. Bad. Worse, some function misunderstands the variable and uses it for something else, damaging it. Later, often much later, the program crashes, but not at a point that makes any sense. Data encapsulation is the concept of making variable (attributes) of a class be totally private to that class. The defined, or exposed, methods and (sometimes) attributes of a class is called the public interface. So long as that public interface does not change, then any user of that class does not need to be changed when the non-public part of the class changes.
What language is completely object oriented c plus plus or java?
Java is the complete object oriented Programming Language as every thing in java is an object,
What is the maximum count of decimal of a 5-bit binary counter?
A 5-bit binary counter, interpreted as an unsigned integer, has a range of 0 to 31. Interpreted as a two's complement signed integer, it has a range of -16 to +15.
datasheet
Local function variables defined static remain in memory at all times. Such variables are only in scope (accessible) when the function itself is in scope.
What are C arithmetic instructions?
C does not have instructions of any kind, it has operators and functions. The arithmetic operators are provided for all built-in numeric types (integer and real numbers, including mixed mode arithmetic). They are as follows:
Unary operators:
positive (+) e.g., +x
negative (-) e.g., -x
prefix increment (++) e.g., ++x prefix decrement (--) e.g., --x
postfix increment (++) e.g., x++
postfix decrement (--) e.g., x--
Binary operators:
add (+) e.g., x + y
subtract (-) e.g., x - y
multiply (*) e.g., x * y
divide (/) e.g., x / y
modulo (%) e.g., x % y
When you open a file in write mode, eg.
fp=fopen("filename.txt","w");
the content of the file is deleted.
Factorial number's summation's program upto n numbers in c language?
#include#includeint a,f,n,sum=0; printf("Enter any number"); scanf("%d",&n); f=1; for(a=1;a<=n;a ); { f=f*a; } for(f=1;f<=n;f ); { sum=sum f; } printf("sumation of factorial numbers :",sum); getch(); }
What is the value of a C Frame 38 SW special?
Smith & Wesson did not make a "C" frame, but they did use the 'C' prefix on various models made between 1948 and 1967. Value would depend on which model you have, originality and condition. sales@countrygunsmith.net
How to multiply two int pointer variable in C language?
You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *
Function to reverse the binary short integer?
You mean the byte-order?
x=((x>>8)&0xff) | ((x&0xff)<<8);
Write a program to eliminate the blanks from string 8085?
public class RemoveSpace{
public static void main(String args[]){
String str = "8085";
Sysytem.out.println(str.trim());
}
}
Get The Desired OutPut....
What is the benift of learning c language?
You will be able to understand C programs. Also to write C programs.
What is the difference between Imperative object-oriented functional and logic programming?
These are all programming paradigms; they describe the "style" used to build the structure and elements of a computer program.
Imperative programming is typically contrasted with declarative programming because they are mutually-exclusive (you won't find any programming languages that are both imperative and declarative), in the same way that you won't find any languages that have both a structured paradigm and a non-structured paradigm. The main difference between the two is that imperative programming describes how a result is to be achieved without specifying what is to be achieved, whereas declarative programming describes what is to be achieved without specifying how it is to be achieved.
Another key difference is that imperative programming makes extensive use of changing-state and mutable data whereas declarative programming does not. Put simply, there are no assignment operations or side-effects in declarative programming.
Given that the object-oriented programming (OOP) paradigm is based upon objects with member methods that can mutate the object's attributes, OOP is based upon the imperative paradigm.
The functional programming paradigm is not to be confused with function calls which are based upon the procedural programming paradigm, which is itself based upon the structured programming paradigm, both of which are imperative. By "functional" we really mean mathematical functions, which are declarative. Although there are some imperative languages that do allow a type of functional programming style, at best they are a grey area because of the side-effects.
Logical programming is also declarative and is based on relations.
What language is admiral from?
Arabic Admihr al bahr Commander of the sea
Answer Strictly speaking, admiral came from amir-al meaning "commander of..." or "emir". The bahrmeans "sea". It did not come directly to English from Arabic, but rather through the Romance languages (Latin-based) as amiralwith the "d" later added in English usage.
How to write java program without using main method?
We need a main method for executing a program.
But YES we can write a program without using main() method.
TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.
TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main method
Whoa!!!!! we are done.
;)