#include<stdio.h>
#include<conio.h>
// note: this code does not test for user-input errors!!
int main() {
int array[10],i,n;
printf("enter the number of elements in the array:");
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&array[i]);
printf("the reverse ordered array is :");
for(i=n-1;i>=0;i--) printf("%d",array[i]);
return 0;
}
01 #include
03#include
04
05 int main()
06{
07 int *ptr,i,n;
08 clrscr();
09 printf("Enter the no of elements:");
10 scanf("%d",&n);
11 ptr=(int *)malloc(sizeof(int)*n);
12 if(ptr==NULL)
13 {
14 printf("Not enough memory");
15 exit(1);
16 }
17 for(i=0; i 18 { 19 printf("Enter %d element : ",i+1); 20 scanf("%d",&ptr[i]); 21 } 22 printf("Array in original order\n"); 23 for(i=0; i 24 { 25 printf("%d\n",ptr[i]); 26 } 27 printf("Array in reverse order\n"); 28 for(i=n-1; i>=0; i--) 29 { 30 printf("%d\n",ptr[i]); 31 } 32 getch(); 33 return 0; 34 }
#include
Get the Array Elements. Create another array. Using loops, copy the values reversely.
find even number in array
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
Well maybe you can make another form show() but make its opacity 0 so people wont know the secret behind it, no the other form, make it display the array backwards and use the print dialog to print the hidden form.
maxValue = function (array) {mxm = array[0];for (i=0; i<array.length; i++) {if (array[i]>mxm) {mxm = array[i];}}return mxm;}; i don't know
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
#include<stdio.h> void main() { int *p,n,s=0; printf("Enter Number :"); scanf("%d",&n); for(p=&n;*p>0;p++) { s=s*10+*p%10; *p=*p/10; } printf("Reverse Number=%d",s); }
find even number in array
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
Well maybe you can make another form show() but make its opacity 0 so people wont know the secret behind it, no the other form, make it display the array backwards and use the print dialog to print the hidden form.
maxValue = function (array) {mxm = array[0];for (i=0; i<array.length; i++) {if (array[i]>mxm) {mxm = array[i];}}return mxm;}; i don't know
Use for loop declare string array str[] and string variable l= string length of string array j=l for i=0 to i=l/2 then temp=str[i] str[i]=str[j-1] str[j-1]=temp j=j-1 now print str array it will be reversed
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
/* PROGRAM TO SORT ARRAY ELEMENTS USING BUBBLE SORT*/ #include #include void main() { int i,j,n,t,a[50]; clrscr(); printf("ENTER THE ARRAY SIZE:\n"); scanf("%d",&n); printf("ENTER THE ARRAY ELEMENTS:\n"); for(i=0;i
The simplest way is probably to read the numbers into an array and then prints each element of the array starting at the last one and moving backwards.
int youArray[arraysize] = {...};...for (int i = 1; i
In python, type the following into a document. NOTE: Sentences following a # symbol are comments, and are not necessary for the program to run. #!/usr/bin/python #This program takes a input from a user and reverses it. number = input("Type a number: ") #This takes input from a user. a = len(number) #This finds the length of the number reverse = "" #This sets the variable reverse to an empty string. for i in number: a = a-1 #The places in a string start from 0. The last value will be the length minus 1.reverse = reverse + number[a] #Makes the number's last digit the new string's first. print("The reverse of", number, "is", reverse + ".") #prints the resulting string. This program will take any sequence of characters and reverse them. The final value is a string, but if an integer is needed, one needs only to add the line reverse = int(reverse) above the print statement. However, this will stop the program from being able to reverse strings, as it is not possible to convert a string to an integer if it is not a number.
// While this doesn't prompt the user for input, it does reverse the values' contents. $intA = '10'; $intB = '20'; $tmp = $intA; $intB = $intA; $intA = $tmp; print $intA; // 20 print $intB; // 10 // An even quicker way is... list($b,$a) = array($a,$b);