Write a program to accept a string and an index from user and displays the character at that specific index.

C File =>


/* Write a program to accept a string and an index from user and
displays the character at that specific index. */


#include<stdio.h>
#include<string.h>
int main() {
char s[30];
int index,i;
printf("\n Enter String and index : ");
scanf("%s%d",s,&index);
printf("\n Character at index %d is : %c",index,s[index-1]);
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”.