If the statement in c program not terminated with semicolon what will it hinder?
Basically, because semicolons are required for terminating statements, it will hinder pretty much everything after the missing semicolon. Without it being there, the compiler will interpret your code incorrectly.
How do you overcome drawbacks of linked list?
Overcoming the "drawbacks" of a linked list requires knowing what drawback is at stack.
If you need to iterate backwards as well as forwards, then you could create a doubly linked list.
If you need to search for elements quickly, then you could implement a binary tree.
If you have a static size, then you could implement an array.
It's all a matter of tradeoff, and of what your particular issue is...
Its badsector...
According to my self disadvantage of link list that searching in link list is sequential if you compare it with arrays its very slow. Because in link list we have to search every node for that. if any one uses binary tree that is in some cases more faster than arrays.
Write a program to generate the first 50 perfect numbers?
I don't believe that 50 perfect numbers have ever been found, last time I checked there were only about 47 known perfect numbers. It would also require an extremely powerful computer.
How do you write the following numbers as the sum of two primes a. 50 b. 36 c. 44?
43 + 7 = 50
17 + 19 = 36
41 + 3 = 44
What is a program to sort a two dimensional integer array?
Any multi-dimensional array can be flattened into a linear array. For instance,
[[1,2,3],[4,5,6],[7,8,9]]
can be flattened into
[1,2,3,4,5,6,7,8,9].
So a solution to your problem (certainly not the most efficient) would be to flatten the 2d array into a linear array, and sort using a traditional sorting algorithm or Arrays.sort. You would then insert the sorted elements back into the 2d array. This would have nlog(n) complexity.
An implementation below:
public static void sort2d(int[][] arr)
{
int r = arr.length;
int c = arr[0].length;
int[] flat = new int[r*c];
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
flat[i*c+j] = arr[i][j];
Arrays.sort(flat);
for (int i = 0; i < flat.length; i++)
arr[i/r][i%c] = flat[i];
}
Write a program of displaying numbers in shape of triangles by using looping?
#include <stdio.h>
int main (void)
{
int i,j;
for (i=1;i<5;i++)
{
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
return 0;
}
What happen when a c program passes an array as a function argument?
When an array name is passed as a function argument, the address of the first element is passed to the function. In a way, this is implicit call by reference. The receiving function can treat that address as a pointer, or as an array name, and it can manipulate the actual calling argument if desired.
How do you toggle case of string in c code. Example is TogGle will turn into tOGgLE?
#include<stdio.h> int main() { char str[100]; int i; printf("Please enter a string: "); // gets(str); // fgets is a better option over gets to read multiword string . fgets(str, 100, stdin); // Following can be added for extra precaution for '\n' character // if(str[length(str)-1] == '\n') str[strlen(str)-1]=NULL; for(i=0;str[i]!=NULL;i++) { if(str[i]>='A'&&str[i]<='Z') str[i]+=32; else if(str[i]>='a'&&str[i]<='z') str[i]-=32; } printf("String in toggle case is: %s",str); return 0; }
How can we create an unsized array to c programme?
Use a pointer...
int a*;
a = malloc(sizeof(int)*100); //allocate space for 100 elements
free(a);
a = malloc(sizeof(int)*1000); // allocate space for 1000 elements
free(a);
#include<stdio.h>
const unsigned int rows = 10;
const unsigned int cols = 3;
int table[rows][cols];
int square (const int n) {
return n * n;
}
int cube (const int n) {
return n * n * n;
}
void initialise_table (void) {
int x, y, val;
for (x=0; x<rows; ++x) {
val = x+1;
table[x][0] = val;
table[x][1] = square (val);
table[x][2] = cube (val);
}
}
int main (void) {
int x, y;
initialise_table ();
printf ("Value\tSquare\tCube\n");
for (x=0; x<rows; ++x) {
printf("%d\t%d\t%d\n", table[x][0], table[x][1], table[x][2]);
}
return 0;
}
Write a c programme to perform Lagrange's interpolation formula?
#include<stdio.h> #include<conio.h> #include<math.h> void
main() { float
x[10],y[10],temp=1,f[10],sum,p; int
i,n,j,k=0,c; clrscr(); printf("\nhow many record you will be enter: "
); scanf("%d"
,&n); for
(i=0; i<n; i++) { printf("\n\nenter the value of x%d: "
,i); scanf("%f"
,&x[i]); printf("\n\nenter the value of f(x%d): "
,i); scanf("%f"
,&y[i]); } printf("\n\nEnter X for finding f(x): "
); scanf("%f"
,&p); for
(i=0;i<n;i++) { temp = 1; k = i; for
(j=0;j<n;j++) { if
(k==j) { continue
; } else
{ temp = temp * ((p-x[j])/(x[k]-x[j])); } } f[i]=y[i]*temp; } for
(i=0;i<n;i++) { sum = sum + f[i]; } printf("\n\n f(%.1f) = %f "
,p,sum); getch(); }
How do you write a recursive function for summing ints?
for example "sumNums(12345)" would sum 1+2+3+4+5.
the recursive code is just really confusing me.
unsigned sumDigits (unsigned n)
{
. . if (n<10) return n;
. . else return n%10 + sumDigits (n/10);
}
Why array indexes starts from zero in c-language?
In order to provide modulo (%) facilities as far as mathematics and logic is concern.
for instance , if we have no of employees in our list say 1545 and if we want to accommodate it within small and effective range then by using % we can do it easily....
we can arrange it in the range within Array with maximum index 14 (0,1,2,.....14).
And 0,15,30,45......1545 will belongs to same category say index no 0.
Think if 0 is not included into index then where we would store 0,15,30,45....1530,1545 .
From a technical standpoint, you need to understand that an array is basically just the starting address of a chunk of memory. The "index" of the array is actually an address offset. So the value at the 0th position would be stored at the address of the array plus zero. The value at the 1st position would be stored at the address plus one, and so on.
Program to check whether the given number is an Armstrong number?
<html>
<head>
<Script Language="JavaScript">
var a,n,b=0,t;
n=parseInt(window.prompt("enter n","0"));
t=n;
while(n>0)
{
a=n%10;
b=b+a*a*a;
n=n/10;
}
if(b==t)
{
document.writeln("Armstrong no");
}
else
{
document.writeln("Not an Armstrong no");
}
</script>
</head>
</html>
You normally create a thread when you want to run a function in the background while processing other things.
Where is it possible to buy an Obagi C?
The best place to purchase an Obagi C online is lovelyskin because they are currently offering a 20 percent discount. There are also authorized Obagi dealers that you can find on their website through the find a dealer option.