Write a program to accept a string and an index from user and displays the character at that specific index.
Get link
Facebook
X
Pinterest
Email
Other Apps
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; }
C File => /* Write a program to accept and display details of 5 students (roll no, name, percentage) using structure. */ #include<stdio.h> #include<stdlib.h> typedef struct Student { int rno; char name[50]; float perc; }; int main() { struct Student s[5]; int i; for(i=0;i<5;i++) { printf("\n\n Enter Roll no. : "); scanf("%d",&s[i].rno); printf("\n Enter Name : "); scanf("%s",s[i].name); printf("\n Enter percentage : "); scanf("%f",&s[i].perc); } printf("\n\n Given details are : "); for(i=0;i<5;i++) { ...
C File => /* Write a program to display the command line arguments in reverse order */ #include<stdio.h> #include<stdlib.h> int main(int argc,char * argv[]) { int i; for(i=argc-1;i>0;i--) printf("\n Argument [%d] is : %s",i,argv[i]); return 0; }
C File => /* Write a C program to accept names of n cities and search for city named “Pune” */ #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int n,flag=0,i; char str[50][50]; printf("\n Enter how many strings? "); scanf("%d",&n); for(i=0;i<n;i++) { printf("\n Enter String%d : ",i+1); scanf("%s",str[i]); } for(i=0;i<n;i++) { if(strcmp(str[i],"Pune")==0) { flag=1; break; } } if(flag==1) printf("\n Pune is found.."); else printf("\n Pune NOT found.."); return 0; }
Comments
Post a Comment
Please do not enter any spam link in message.