diff --git a/Q16_reverse_string.c b/Q16_reverse_string.c index 16834b6..30eb51f 100644 --- a/Q16_reverse_string.c +++ b/Q16_reverse_string.c @@ -1,22 +1,11 @@ -#include -#include -void main() +#include +#include +int main() { - int i, j, k; - char str[100]; - char rev[100]; - printf("Enter a string:\t"); - scanf("%s", str); - printf("The original string is %s\n", str); - for(i = 0; str[i] != '\0'; i++); - { - k = i-1; - } - for(j = 0; j <= i-1; j++) - { - rev[j] = str[k]; - k--; - } - printf("The reverse string is %s\n", rev); - getch(); + char s[100]; + printf("Enter a string\n"); + gets(s); + strrev(s); + printf("Reverse string is: %s\n", s); + return 0; } diff --git a/check if the number formed by the last digit of each element of an array is divisible by 10 or not b/check if the number formed by the last digit of each element of an array is divisible by 10 or not new file mode 100644 index 0000000..45eb92a --- /dev/null +++ b/check if the number formed by the last digit of each element of an array is divisible by 10 or not @@ -0,0 +1,15 @@ +#include +int main() +{ + int a[100],i,n; + printf("enter size of array\n"); + scanf("%d ", &n); + printf("enter array\n"); + for(i=0;i