"I LOVE MY COUNTRY"
write a c program to get "COUNTRY MY LOVE I" as the output.
Use any other programming language. It is not mandatory to
use C.
Answer Posted / elle
#include<stdio.h>
#include<malloc.h>
#include<string.h>
#define MAX 20 //define size
int main()
{
int len,j=0;
char *p, *line[MAX],*q;
p=(char *)malloc(MAX);
char *l="i love my country";
int i=0;
while(*l!='\0')
{
if(*l==' ')
//whenever a space is encountered, copy the string q into
//the array
{
*p='\0';
line[i]=(char *)malloc(MAX);
strcpy(line[i],q);
strcpy(p,"");
l++;
i++;
j=0;
}
else
{
if(j==0)
{
q=p;
}
*p=*l;
l++;
p++;
j++;
}
}
*p='\0';
line[i]=(char *)malloc(MAX);
strcpy(line[i],q);
printf("printing in reverse\n");
while(i>=0)
{
printf("%s ",line[i]);
i--;
}
}
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.
Why isn't it being handled properly?
What is the Purpose of 'extern' keyword in a function declaration?
Why can’t constant values be used to define an array’s initial size?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
What are the types of macro formats?
What is a function in c?
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
provide an example of the Group by clause, when would you use this clause
Can you please explain the difference between exit() and _exit() function?
What are 'near' and 'far' pointers?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What is the use of ?: Operator?
How do you list a file’s date and time?