how can i sort numbers from ascending order and descending
order using turbo c..
Answer / neha
If you are using the String class to store your names then you can use the < or > operators to compare the order, alphabetically, they appear in.
String names[3];
int numberOfNames = 3;
names[0] = "abc";
names[1] = "dfg";
names[2] = "hij";
printf("before %s%s%s\n", names[0],names[1],names[2]);
for( int i = 0; i < numberOfNames-1; i++ )
{
for( int j = 0; j < numberOfNames; j++ )
{
if( names[j] < names[j+1] )
{
names[j].swap( names[j+1] );
}
}
}
printf("after%s%s%s\n", names[0],names[1],names[2]);
output:
before abcdfghij
after hijdfgabc
Is This Answer Correct ? | 4 Yes | 6 No |
Explain function?
Explain following declaration int *P(void); and int (*p)(char *a);
How can I rethow can I return a sequence of random numbers which dont repeat at all?
size maximum allocated by calloc()
Define VARIABLE?
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.
what different between c and c++
what type of language is C?
What is static identifier?
What is an auto keyword in c?
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }
What ios diff. Between %e & %f?