string problems
#include <stdio.h>
int main()
{
char str[13] = "Upendra Yadav";
char *ptr = str;
for (int i = 0; i < 13; i++)
{
printf("%c", *ptr);
ptr++;
}
char st[] = "Upendra Bhai";
printf("%s", st);
return 0;
}
#include <stdio.h>
int main()
{
char str1[10];
char str2[10];
char c;
printf("enter the name of Users:");
scanf("%s", str1);
printf("%s", str1);
return 0;
}
#include <stdio.h>
int strlen(char *str)
{
char *ptr = str;
int len = 0;
while (*ptr != '\0')
{
len++;
ptr++;
}
return len;
}
int main()
{
char str[] = "UpendraYadav";
int l = strlen(str);
printf("The length of string is %d", l);
return 0;
}
#include <stdio.h>
int main()
{
char str[] = "Upendra";
char *ptr = str;
int n = 0;
while (*ptr != '\0')
{
n++;
ptr++;
}
printf("the length of string is %d ", n);
return 0;
}
#include <stdio.h>
void slice(char *str, int a, int b)
{
int i = 0;
while (i < b)
{
str[i] = str[i + a];
i++;
}
str[i] = '\0';
}
int main()
{
char str[] = "Upendraduiadhuaduha";
slice(str, 1, 10);
printf("%s", str);
return 0;
}
# include<stdio.h>
# include<string.h>
int main(){
char st[]="Upendra";
char st1[20];
strcpy(st1,st);
printf("%s",st1);
return 0;
}
#include <stdio.h>
int main()
{
char st[] = "Upendra";
char *ptr = st;
return 0;
}
# include<stdio.h>
void Encript(char *c){
char *ptr=c;
while (*ptr!='\0')
{
*ptr=(*ptr-65)/45;
ptr++;
}
}
int main(){
char c[]="Hey Guys Come To come I want U";
Encript(c);
printf("Encript message is :%s",c);
return 0;
}
# include<stdio.h>
void Decript(char *c){
char *ptr=c;
while (*ptr!='\0')
{
*ptr=*ptr;
ptr++;
}
}
int main(){
char c[]="BCCABCCCAABCCCABCACCCCABACCCCAB";
Decript(c);
printf("decript message is :%s",c);
return 0;
}
#include <stdio.h>
int Counting(char *c)
{
char *ptr = c;
int n = 0;
while (*ptr != '\0')
{
n++;
ptr++;
}
return n;
}
int main()
{
char c[] = "Upendra";
int a = Counting(c);
printf("No . of character in given string is %d", a);
return 0;
}
#include <stdio.h>
int Occurence(char *c, char b)
{
char *ptr = c;
int n = 0;
while (*ptr != '\0')
{
if (*ptr == b)
{
n++;
}
ptr++;
}
return n;
}
int main()
{
char c[] = "Yadav8888888";
int b = Occurence(c, '8');
printf("%d time occurced", b);
return 0;
}
#include <stdio.h>
void check_ch(char *c, char a)
{
char *ptr = c;
while (*ptr != '\0')
{
if (*ptr == a)
{
}
ptr++;
}
printf("character is present");
}
int main()
{
char c[] = "Yogesh";
check_ch(c, 'a');
return 0;
}
#include <stdio.h>
int main()
{
char str[] = {'U', 'P', 'E', 'N', 'D', 'R', 'A', '\0'};
char *ptr = str;
while (*ptr != '\0')
{
printf("%c", *ptr);
ptr++;
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char *str1 = "Upendra";
char str2[10] = "Upendra";
int val = strcmp(str1, str2);
printf("The value us %d", val);
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char str1[20] = "hello";
char *str2 = "Upendra";
strcat(str1, str2);
printf("Hey bro %s", str1);
return 0;
}
#include <stdio.h>
int main()
{
char str[20];
printf("Enter Urs name:\n");
scanf("%s", str);
printf("Your name is %s", str);
return 0;
}
#include <stdio.h>
int main()
{
char str[50];
printf("Enter Urs Name:");
gets(str);
puts(str);
return 0;
}
# include<stdio.h>
int main(){
char *ptr="Upendra Yadav";
char ptr1[]="Upendra Yadav";
printf("%s\n",ptr);
printf("%s",ptr1);
return 0;
}
No comments:
Post a Comment