answersLogoWhite

0


Best Answer

It is not ambiguous. There is something wrong with the question. Please restate the question.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why is passing a uint64 t to a function that takes uint64 t as the only argument ambiguous?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Factorial in c program using for loop?

#include<stdio.h> #include<conio.h> void main() { int i,n,fact=1; clrscr(); printf("enter the number"); scanf("%d",&n); for(i=1;i<=n;i++) printf("%d",n); fact=fact*i; { printf("the factorial is=%d",fact); } getch(); } By:-Abhishek Goyal(goyal.abhi40@yahoo.com)


What are the advantages of using typedef in a program?

1. Readability. Just like naming your variables properly can show how you intend to use the variable, renaming the type can help show how you intend to use all variables of this type. It eliminates the possible bug of incorrect argument ordering (e.g. if a method signature has multiple boolean flags). 2. Portability. On different systems you might want to have the same variable name (because you're using it the same way) to be of a different type. So you keep the typedef in a header file controlled by conditional compilation (for example) for maximal portability. 3. decreases complexity for declaring complex and repeated declarations like typedef unsigned long int UINT64;


What are the advantages of using a recursive function in c?

Advantages:Through Recursion one can Solve problems in easy way whileits iterative solution is very big and complex.Ex : tower of HanoiYou reduce size of the code when you use recursive call.Disadvantages :Recursive solution is always logical and it is verydifficult to trace.(debug and understand)Before each recursive calls current values of the variblesin the function is stored in the PCB, ie process controlblock and this PCB is pushed in the OS Stack.So sometimes alot of free memory is require for recursivesolutions.Remember : whatever could be done through recursion could bedone through iterative way but reverse is not true.


User defined data types in c plus plus?

C++ provides the following fundamental types:A Boolean type (bool)Character types (char and wchar_t)Integer types (int, short, long and long long)Floating-point types (float, double and long double)A type, void, used to signify the absence of information.Fundamental types correspond to the basic storage units of the machine. From the fundamental types we can construct other types using declarator operators:Pointer types (such as int*)Array types (such as char[])Reference types (such as double& and char&&)The Boolean, character and integer types are collectively known as the integral types. The integral and floating-point types are collectively known as the arithmetic types.The fundamental types, pointers, arrays and references are collectively known as the built-in types.The integral types can be further modified using the signed or unsigned modifiers. Strictly speaking, both long and short are also type modifiers because a short implies a short int. This is simply an artefact from C programming where int was implied in the absence of an explicit type.Note that aliases (using x = type) and type definitions (typedef) are not types per se, they are simply alternative names for preexisting types. For instance, although wchar_t is a built-in type because it does not require a declaration, in reality it is just an alias for an implementation-defined integral type (typically unsigned short).From these built-in types we can construct other types:Data structures and classes (such as std::vector and std::string)Enumeration types (enum and enum class)Data structures, classes and enumeration types are collectively known as user-defined types.In essence, any type that requires an explicit declaration is a user-defined type. This includes all C++ standard library types such as std::string because we cannot use a std::string object unless we include the header where the type is declared.


How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

// returns n! int fact(final int n) { // keep track of factorial calculation in f // f starts at n, and we will multiply it by all integers less than n int f = n; // loop from n-1 down to 2 for(int i = (n - 1); i > 1; --i) { // increase our total product f *= i; } return f; }

Related questions

Factorial in c program using for loop?

#include<stdio.h> #include<conio.h> void main() { int i,n,fact=1; clrscr(); printf("enter the number"); scanf("%d",&n); for(i=1;i<=n;i++) printf("%d",n); fact=fact*i; { printf("the factorial is=%d",fact); } getch(); } By:-Abhishek Goyal(goyal.abhi40@yahoo.com)


How do you compute the binary equivalent of a number using a recursive function using C or C plus plus?

Recursion is not the best way of dealing with this. An iterative function would be more efficient. However, the following recursive method will get the job done, if somewhat slowly and painfully (the equivalent iterative method is also shown, with performance timings for comparison): #include <Windows.h> #include <iostream> typedef unsigned long long UINT64; char * Dec2BinRecur( UINT64 Dec, char *Bin, size_t Length ) { if( Length ) { Bin[--Length] = Dec & 1 ? '1' : '0'; Dec2BinRecur( Dec >> 1, Bin, Length ); } return( Bin ); } char * Dec2BinIter( UINT64 Dec, char *Bin, size_t Length ) { while( Length ) { Bin[--Length] = Dec & 1 ? '1' : '0'; Dec >>= 1; } return( Bin ); } int main() { char strFormat[] = "Dec2Bin %I64u %s: %.2f microseconds Answer: %s\n"; LARGE_INTEGER Freq, Start, Finish; QueryPerformanceFrequency( &Freq ); double Recur, Iter; char Bin[65]; memset( Bin, 0, 65 ); memset( Bin, '0', 64 ); UINT64 Dec = 18446744073709551615; QueryPerformanceCounter( &Start ); Dec2BinRecur( Dec, Bin, 64 ); QueryPerformanceCounter( &Finish ); Recur = ( double ) ( Finish.QuadPart - Start.QuadPart ) / Freq.QuadPart; printf( strFormat, Dec, "Recursive", Recur * 1000000, Bin ); QueryPerformanceCounter( &Start ); Dec2BinIter( Dec, Bin, 64 ); QueryPerformanceCounter( &Finish ); Iter = ( double ) ( Finish.QuadPart - Start.QuadPart ) / Freq.QuadPart; printf( strFormat, Dec, "Iterative", Iter * 1000000, Bin ); return( 0 ); } Output: Dec2Bin 18446744073709551615 Recursive: 9.84 microseconds Answer: 1111111111111111111111111111111111111111111111111111111111111111 Dec2Bin 18446744073709551615 Iterative: 1.72 microseconds Answer: 1111111111111111111111111111111111111111111111111111111111111111


What are the advantages of using typedef in a program?

1. Readability. Just like naming your variables properly can show how you intend to use the variable, renaming the type can help show how you intend to use all variables of this type. It eliminates the possible bug of incorrect argument ordering (e.g. if a method signature has multiple boolean flags). 2. Portability. On different systems you might want to have the same variable name (because you're using it the same way) to be of a different type. So you keep the typedef in a header file controlled by conditional compilation (for example) for maximal portability. 3. decreases complexity for declaring complex and repeated declarations like typedef unsigned long int UINT64;


What are the advantages of using a recursive function in c?

Advantages:Through Recursion one can Solve problems in easy way whileits iterative solution is very big and complex.Ex : tower of HanoiYou reduce size of the code when you use recursive call.Disadvantages :Recursive solution is always logical and it is verydifficult to trace.(debug and understand)Before each recursive calls current values of the variblesin the function is stored in the PCB, ie process controlblock and this PCB is pushed in the OS Stack.So sometimes alot of free memory is require for recursivesolutions.Remember : whatever could be done through recursion could bedone through iterative way but reverse is not true.


How do you instantiate a complex number?

The following are the different ways to assign a value to a complex number:By passing two Double values to its constructor. The first value represents the real, and the second value represents imaginary part of a complex number.For example,Complex c1 = new Complex(5, 8); /* It represents (5, 8) */By assigning a Byte, SByte, Intl6, UIntl6, Int32, UInt32, Int64, UInt64, Single, or Double value to aComplex object. The assigned value represents the real part of the complex number, and its imaginary part becomes0. For example,Complex c2 = 15.3; /* It represents (15.3, 0) */By casting a Decimal or BigInteger value to a Complex object.For example,Complex c3 = (Complex) 14.7; /* It represents (14.7, 0) */Assigning the value returned by an operator to a Complex variable.For example,Complex c4 = c1 + c2; /* It represents (20.3, 8) */


User defined data types in c plus plus?

C++ provides the following fundamental types:A Boolean type (bool)Character types (char and wchar_t)Integer types (int, short, long and long long)Floating-point types (float, double and long double)A type, void, used to signify the absence of information.Fundamental types correspond to the basic storage units of the machine. From the fundamental types we can construct other types using declarator operators:Pointer types (such as int*)Array types (such as char[])Reference types (such as double& and char&&)The Boolean, character and integer types are collectively known as the integral types. The integral and floating-point types are collectively known as the arithmetic types.The fundamental types, pointers, arrays and references are collectively known as the built-in types.The integral types can be further modified using the signed or unsigned modifiers. Strictly speaking, both long and short are also type modifiers because a short implies a short int. This is simply an artefact from C programming where int was implied in the absence of an explicit type.Note that aliases (using x = type) and type definitions (typedef) are not types per se, they are simply alternative names for preexisting types. For instance, although wchar_t is a built-in type because it does not require a declaration, in reality it is just an alias for an implementation-defined integral type (typically unsigned short).From these built-in types we can construct other types:Data structures and classes (such as std::vector and std::string)Enumeration types (enum and enum class)Data structures, classes and enumeration types are collectively known as user-defined types.In essence, any type that requires an explicit declaration is a user-defined type. This includes all C++ standard library types such as std::string because we cannot use a std::string object unless we include the header where the type is declared.


How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

// returns n! int fact(final int n) { // keep track of factorial calculation in f // f starts at n, and we will multiply it by all integers less than n int f = n; // loop from n-1 down to 2 for(int i = (n - 1); i > 1; --i) { // increase our total product f *= i; } return f; }


What is naming variable?

A variable is a storage location, effectively. It stores information, only whilst your program is running. For instance, Dim Num As Integer = 0 Dim, declares our variable - this is short for Dimension, as it sets aside memory space (random access memory). Num is the name of our Variable, we can refer back to this at later dates. For instance: Dim Num As Integer = 0 'This is our variable Bla bla bla Num = 9 This creates our variable 'Num' and sets it as a Integer. It then assigns the Variable a value (0) Then, it does some code (bla bla bla - Note, this code won't work, it's just used as an example!) Then, we edit the value of our Variable by simply typing "Num = 9" As Integer = This declares the data type, this means we want a Integer (Number) as a data type. Some examples of different data types are: Boolean Byte Char DateTime Decimal Double Int16 Int32 Int64 SByte Single UInt16 UInt32 UInt64 And then that's it! I hope I explained it easily enough for you to understand and remember, no matter how hard you think it is keep trying and you'll get it in no time!


Write a c program to find Armstrong number using ifstatement?

#include<stdio.h> int main(){ int num,r,sum,temp; int min,max; printf("Enter the minimum range: "); scanf("%d",&min); printf("Enter the maximum range: "); scanf("%d",&max); printf("Armstrong numbers in given range are: "); for(num=min;num<=max;num++){ temp=num; sum = 0; while(temp!=0){ r=temp%10; temp=temp/10; sum=sum+(r*r*r); } if(sum==num) printf("%d ",num); } return 0; }


What are the various data types in C plus plus?

Data types specify how data is interpreted. All data in a binary computer is stored as a sequence of bits (binary digits), thus all data is represented by numeric values. The data type associated with that data determines how many bits the data occupies and how that data should be interpreted. For instance, an unsigned char data type occupies 8 bits (1 byte) which translate to a numeric value in the range 0 to 255. These values map to ASCII character codes in the current code page, thus if you were to output a char data type it would print the character associated with the character code rather than the numeric value of the code. Unicode character codes use 16 bits (2 bytes) to represent each character and are therefore unsigned short types, also known as wchar_t types. The primitive data types include int, short and char, which are all integral data types used to store integers (whole numbers). Each may be further qualified with the signed or unsigned keywords, thus a signed char will represent values in the range -128 to +127. Strings of characters are represented as an array of char types, typically terminated by a null character which has the value 0. Arrays are simply sequence containers containing one or more data elements of the same type. Since the length of each element is the same, it is trivial to locate any element within the array given the element's index where the first element can be found at index 0. Thus an array of n elements will have indices in the range 0 to n-1. Knowing the size of each element (as determined by its type) means that element x can be found at the memory address x*sizeof(element) bytes from the start of the array, using nothing more than simple pointer arithmetic. However, when you declare an array, the subscript operator can be used to specify the index of the element you wish to examine, while C++ does the pointer arithmetic in the background. More complex data types can be declared using class or struct keywords. The declaration of these types determines how they are mapped in memory and ultimately how they are interpreted. Primitive data types act as the building blocks for these complex data types, but more complex data types can be composed from any combination of primitive and pre-existing complex data types to produce ever more highly complex data types. Instances of a type are known as variables or constants, depending on whether the value of the instance can be changed or not. If the type is a complex data type, such as a class or struct, the instance is known as an object, which can also be variable or constant. Many new users regard classes and objects as being the same thing, however a class is the definition of a type while an object is an instance of the type, in the same way that a char is a type while a char variable is an instance of the type.


How do you write a program in c to get the factorial of a number?

There are two ways to implement a factorial function. The first is the conventional method using a constexpr function: constexpr fct (unsigned n) { return (i < 2) ? 1 : n * fct (n - 1); } This has the advantage in that it can be used for both compile-time and runtime computation: constexpr unsigned x = fct (5); // compile-time computation A good compiler will perform the complete calculation at compile-time, thus the declaration of x is equivalent to: constexpr unsigned x = 120; // e.g. x = 5 * 4 * 3 * 2 * 1 Conversely, the declaration of y is not constexpr, thus the calculation must be performed at runtime. The same is true of any non-const variable. However, if we only required compile-time computation, then we can use template-metaprogramming instead: template<unsigned N> constexpr unsigned fac (void) { return N*fac<N-1>(); } template<> constexpr int fac<2> (void) { return 2; } Note that we cannot use variables in a template intended for compile-time computation, hence we use a template parameter and a specialisation to enable the recursion. The specialisation for N=2 represents the end-point of recursion. We could also provide a specialisation for N=1 and N=0, however this would be superfluous given that fac<1> and fac<0> both equate to 1 and we'd never deliberately invoke these in code. Note also that the largest integer we can represent with an unsigned integer is UINT_MAX (defined in <limits>). For a 32-bit integer this is (2^32)-1, thus fct<12> is the largest factorial we can calculate. If we use uint64 instead, then we can calculate factorials up to fct<21>. However, the larger the value of N, the less likely we can make use compile-time computation, but we can still make use of partial compile-time computation in conjunction with runtime computation if we use the constexpr version of the function. If we wish to accommodate larger factorials, then we must either use a long double or use a user-defined type that can handle larger integers, however the latter would mean losing compile-time computation altogether.