google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Wednesday, April 1, 2015

C program to accept n number from user store these numbers into an array and sort the numbers of an array.

Write a C program to accept ‘n’ number from user, store these numbers into an array and sort the numbers of an array.

#include<stdio.h>
#include<conio.h>
void main()
{
  int n,a[20],i,j,temp;
  clrscr();
  printf("\n ENTER HOW MANY NO U WANT");
  scanf("%d",&n);
  printf("enter the elements\n");
  for(i=0;i<n;i++)
  {
   scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      if(a[i]<a[j])
      {
  temp=a[i];
  a[i]=a[j];
  a[j]=temp;
      }
    }
   }
   printf("\nSORTED ARRAY ELEMENTS \n");
   for(i=0;i<n;i++)
   {
     printf("%d\t",a[i]);
   }
   getch();
  }

C program to accept customer details

Write a ‘C’ program to accept customer details such as: Account_no, Name, Balance in account, Assume Maximum 20 customers in the bank.
Write a function to print the account no and name of each customer with
balance below Rs.100.

Solution:-

#include<stdio.h>
#include<conio.h>
struct customer
{
int accno;
char cname[20];
int bal;
};
void disp(struct customer * , int);
void main()
{
struct customer c[20];
int i,n;
clrscr();
printf("\nHOW MANY CUSTOMER U WANT");
scanf("%d",&n);
printf("\nENTER THE ACCNO,CNAME,BAL");
for(i=0;i<n;i++)
{
scanf("%d%s%d",&c[i].accno,&c[i].cname,&c[i].bal);
}
disp(&c[0],n);

getch();
  }
  void disp(struct customer *d,int n)
  {
    int i;
    for(i=0;i<n;i++)
    {
if(d[i].bal<100)
{
printf("\n%d\t%s",d[i].accno,d[i].cname);
}
    }
 }

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...