Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows
Showing posts with label Arrays (C). Show all posts
Showing posts with label Arrays (C). Show all posts

Sunday, January 9, 2011

Write a program to reverse a string to another string using strrev().


Source Code :

#include<stdio.h>
void main()
{
      char str1[20];
      clrscr();
      printf("\nEnter a String : ");

Write a program to copy a string to another string using strcpy().


Source Code :

#include<stdio.h>
void main()
{
      char str1[20],str2[20];
      clrscr();
      printf("\nEnter a String : ");

Write a program to combine two strings using strcat().


Source Code :

#include<stdio.h>
void main()
{
      char str1[20],str2[20];
      clrscr();

Write a program to find the length of a string using strlen().


Source Code :

#include<stdio.h>
void main()
{
      int len;
      char str[20];

Write a program to calculate sum of given 10 numbers using array.


Source Code :

#include<stdio.h>
void main()
{
      int a[10],i,sum=0;
      clrscr();

Write a program to copy the contents of one array into another in the reverse order.


Source Code :

#include<stdio.h>
void main()
{
      int a[10],b[10],i,j;
      clrscr();
      printf("\nEnter Elements : ");

25 numbers are entered from the keyboard into an array. Write a program to find out how many of them are positive, how many are negative, how many are even & how many odd.


Source Code :

#include<stdio.h>
void main()
{
      int a[25],odd=0,even=0,neg=0,pos=0,i;
      clrscr();
      printf("\nEnter 25 Elements : ");

Tuesday, January 4, 2011

Write a Program to take some values into an array and find the average of these array elements using pointer and user defined function

Source Code :

#include<stdio.h>
void avg(int *p)   //User Defined Function for Calculation of Average
{
      float avg=0;
      int i;
      for(i=0;i<5;i++,p++)
      {
            avg+=*p;
      }
      avg/=5;     //Calculation of Average
      printf("\n\nAverage : %5.2f",avg);  //Display Result
}