C programme language | Code problem solve | Array sorting

Logo source
Today, I have come with something new. I'll represent C Language. As I'm a student of CSE, I thought to share some code with you all guys! Hope it'll help others too.
I'll solve one C code problem.
Here goes the problem :
Given an array named A with following elements: 3, -5, 1, 3, 7, 0, -15, 3, -7, -8 write a programme to shift the negative numbers to the left and positive numbers to the right so that the resultant array look like the -5, -15, -7, -8, 3, 1, 3, 7, 0, 3
Solution :
#include<stdio.h>
int main()
{
int a[10]= {3,-5,1,3,7,0,-15,3,-7,-8},value,i,j;
for(i=0; i<10; i++)
{
value = a[i];
if(value<0)
{
for(j=i; (j>0&&a[j-1]>=0);j--)
a[j] = a[j-1];
a[j]=value;
}
}
for(i=0; i<10; i++)
printf("%4d",a[i]);
}
If you build and run this code, you'll get your desire output.
I used Codeblocks for this code as its simple and easy to use.Download this app and run this code and inform me about your experience.
If you like this post, inform me in the comment box. I'll post again like this kind of things if you guys like it.
That's all for today. I'm taking my leave.
Take lots of love and blessings from @meive.
Leave C programme language | Code problem solve | Array sorting to:
Read more #code posts
Best Posts From meive
We have not curated any of meive's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From meive
- Obsessed for my hills
- Never miss a mirrorfie
- Sweat is sexy.Sweat and glow
- Wanna grab my waist?
- Close to nature
- EYE PAINTING IDEAS | PLAY WITH MAKEUP
- MULTIPLICATION Of TWO ARRAY in C PROGRAMME
- C programme language | Code problem solve | Array sorting
- Dalgona coffee in two style | hot and cold
- Kunafa recipe | Arabian dessert recipe
- Palm painting with acrylic colors | turned around
- Stuff bun in three different way | fry and with or without oven
- Mac and cheese | Baked mac with white sauce
- deleted post
- STOP Plagiarism | Banned Abusive Account from HIVE
- Home made pizza | simple pizza recipe with and without oven
- Sorry for deleting
- Sorry for the wrong post
- Chemistry of Otis and Meave from Sex education | Netflix series
- Strawberry shortcake | Illustration |Adobe illustrator