Q. Write a program to accept a character, an integer n and display the next n characters
Program
#include<stdio.h>
int main()
{
int n,j=1;
char a;
printf("enter char :");
scanf("%c",&a);
printf("enter limit :");
scanf("%d",&n);
while(j<=n)
{
a=a+1;
if(a=='z' || a=='Z')
{
printf("large limit\n");
j=n;
}
else
printf("%c\t",a);
j++;
}
}
Output:
enter char :t
enter limit :5
u v w x y
Program
#include<stdio.h>
int main()
{
int n,j=1;
char a;
printf("enter char :");
scanf("%c",&a);
printf("enter limit :");
scanf("%d",&n);
while(j<=n)
{
a=a+1;
if(a=='z' || a=='Z')
{
printf("large limit\n");
j=n;
}
else
printf("%c\t",a);
j++;
}
}
Output:
enter char :t
enter limit :5
u v w x y
0 Comments