What type of application would you use if the data set is non-numerical?
Non-parametric statistical methods.
Program in c find the largest number out of ten with the help of for loop?
largestNum = 0;
for ( i = 0; i < 10 ; i++)
{
if ( currentNum[i] > largestNum)
largestNum = currentNum[i];
}
How do you check whether the given number is Armstrong or not?
First, review the definition of an Armstrong, or narcissistic, number:
"...is a number that is the sum of its own digits each raised to the power of the number of digits."
So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:
String numberAsString = "" + number;
Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.
Another way is to get one digit at a time, starting from the right, using the "%" operator.
For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.
First, review the definition of an Armstrong, or narcissistic, number:
"...is a number that is the sum of its own digits each raised to the power of the number of digits."
So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:
String numberAsString = "" + number;
Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.
Another way is to get one digit at a time, starting from the right, using the "%" operator.
For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.
First, review the definition of an Armstrong, or narcissistic, number:
"...is a number that is the sum of its own digits each raised to the power of the number of digits."
So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:
String numberAsString = "" + number;
Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.
Another way is to get one digit at a time, starting from the right, using the "%" operator.
For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.
First, review the definition of an Armstrong, or narcissistic, number:
"...is a number that is the sum of its own digits each raised to the power of the number of digits."
So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:
String numberAsString = "" + number;
Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.
Another way is to get one digit at a time, starting from the right, using the "%" operator.
For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.
Explain how to use an array to find 3 x 19?
printf ("3*19 is %d\n", sizeof (char [19][3]));
Warning: never do this in an actual program!
Write a c program to find the sum of numbers between given limits?
int sum (int min, int max) {
return (max-min+1)*(max+min)/2;
}
How do i write An equation that shows the number 3 is a function of number 18?
There are many ways that the number 3 can be written as a function of the number 18. A function of any number (x) is often called f(x).
Let's say that f(x)=k.
So, in this case, x=18 and k=3. In other words, f(18)=3.
Now, you have to think of an equation that could relate the two numbers. For example, the easiest way to show how 3 is related to 18 is to show that 3 times 6 equals 18. Therefore, you could write that 3 = 18/6. And this equation proves that the number 3 is a function of the number 18.
How do you find odd or even in n number of value?
-- First of all, if the number is a fraction or a decimal, then don't worry about it.
Only whole numbers are considered odd or even.
-- All multiples of 2 are even numbers, and that's easy to recognize. It doesn't
matter how big the number is, or how many digits it has. You only have to look
at the last digit (the one on the right-hand end). If that digit is 2, 4, 6, 8, or 0,
then the whole big number is even. Otherwise it's odd.
Two digit number is three more than 7 times the sum of it's digits?
If there are two digits than the first one is ten times its value.
So as an algebraic equation we get
10A + B - 3 = 7(A x B)
This can be simplified to
10A + B - 3 = 7A + 7B
and this reduces to
10A - 7A = 7B - B +3
or
3A =6B +3
A solution to this is
3(3) = 6(2) +3
Which would make the original equation
32 = 7(3+2)-3
How do you write macro programs to calculate average of n numbers?
#include<stdio.h>
#define size 100
int main(){
int x[size], sum=0;
float average;
for(int i=0;i<size;i++){
scanf("%d",x[i]);
sum+=x[i];
}
average=sum/size;
printf("The Average is :\t%d",average);
return 0;
}
How can you print prime numbers uing turbo c?
A prime number is a number that has no factors other than 1 and itself. For instance, 1, 2 and 3 are prime numbers. However, 4 isn't because it can also be divided evenly by 2.
Although a complicated floating-point function can be written to test if the division of a number is even, the C modulus operator (%) is far quicker. If 'n' modulus 'm' is zero, then the division is even - there is no fractional component.
Using this rule, the pseudo-code for testing if a number is prime is as follows:
- if number is zero, return false
- if number is less than 4, return true since 1, 2 and 3 are primes
- iterate a variable 'c' from 2 until the number 'n' minus 1
- if n modulus c is zero, return false, since 'n' has 'c' as a factor
- return true
All that remains is converting the above code to C (or any other programming language) using inline code or a function.
How do you code to check whether the input is numeric value or not in C?
I don't know about C but in C++ I would have the compiler do a bool statement for return type (int, float, long, short, signed short, signed long) and have make them true and have it output. I'm still learning myself so this might not be accurate but it's what I would do.
What is the only integer that can be assigned to a string?
If you wanted to ask 'Which is the only numeric value that can be assigned to a pointer?', then the answer would be: 0.
Can someone right a pseudo code to find a gcd of 2 numbers?
while b is not equal to zero
... temp = b
... b = a mod b
... a = temp
return a
Knuth, Donald E. The Art of Computer Programming, Volume 1: Fundamental Algorithms (3rd ed.) (Section 1.2.1: Mathematical Induction, pp. 319-320.)
Convert binary octal 864BF into hexadecimal?
Okay, I'm pretty sure that 864 binary is 30 hexadecimal. - RG
11100011
C program to find whether the given number is prime or not?
int is_prime(int n){
int flag=1;
if(n==1)
return 0;
int root=(int)sqrt(n);
while(root!=1){
if(n%root==0){
flag=0;
break;
}
root--;
}
return flag;
}
How do you display the prime numbers upto n limit in the c program output?
#include<conio.h>
#include<stdio.h>
void main (void)
{
int a,b,c,d;
printf("enter the max limit : ");
scanf("%d",&a);
for(b=1;b<=a;b++)
{
for (c=2;c<b;c++)
{d=b%c;
if (d==0) break;}
if (d!=0) printf("%d\n",b);}
getch();
}
by WAli Ahsan
Ch-007
Prime factors a number using c language?
#include
#include
void main()
{
int n,i;
clrscr();
printf("Enter a Number:");
scanf("%d",&n);
printf("\n\nPrime Factors of %d is: ",n);
for(i=2;i<=n;i++)
{
if(n%i==0)
{
printf("%d,",i);
n=n/i;
i--;
if(n==1)
break;
}
}
getche();
}
this program will find the prime factors of a given number
any assistance
mail at :- devilllcreature@yahoo.com
thank you
This is typically done by importing math.h, and calling the sqrt function.
Write a C program to convert hexadecimal number into decimal number?
pongada punda vayanungala ..................
C program to find both the largest and smallest numbers in the given list without applying array?
I'll assume the list is supplied as arguments to the program:
#include <stdlib.h>
#include <stdio.h>
main (argc, argv)
int argc;
char **argv;
{
int c = 0, mn, mx, z;
while (--argc)
{
z = atoi(*(++argv));
if (!c++) mx = mn = z;
else if (z > mx) mx = z;
else if (z < mn) mn = z;
}
if (c) printf("%d numbers, min = %d, max = %d\n", c, mn, mx);
else printf("No arguments given: please supply a list of numbers as arguments\n");
}
Any error trapping is left as an exercise.