‘C’ program to accepts a character and integer n as parameter and displays the next 'n' characters.

C File =>


/* Write a function in ‘C’, which accepts a character and integer n as parameter and displays the next 'n' characters. */

#include<stdio.h>
int main() 
{
      int n,i;
      char c;

    // defining function 
      void disp_chars(char ch,int n)
      {
         for(i=1;i<=n;i++)
         {
             printf("%c\t",ch+1);
             ch++;
          }
      }
 
      printf("\n Enter character : ");
      scanf("%c",&c);
      printf("\n Enter value of n : ");
      scanf("%d",&n);
 
      printf("\n Next %d characters are :\n",n);
 disp_chars(c,n);
 
      return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.