1. Write a C program to count the number of occurrence
of
a specific word in the given strings.
(for e.g. Find how many times the word “live” comes in the
sentence “Dream as if you’ll live forever, live as if
you’ll die today ”)
Answers were Sorted based on User's Feedback
Answer / ankur
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[40],ch;
int num;
cout<<"Entre a string :";
cin.getline(str,40);
cout<<"Entre a character :";
cin>>ch;
for(int i=0;i!='\0';++i)
{
if(str[i]==ch)
num=num+1;
}
cout<<num;
getch();
}
| Is This Answer Correct ? | 20 Yes | 74 No |
Answer / jyoti
#include<stdio.h>
#include<conio.h
#include<string.h>
void main()
{
char st[200],nw[20];
int i,j=0;
clrscr();
printf("enter string");
gets(st);
printf("enter new string");
gets(nw);
for(i=0;st[i]!='\0';i++)
{if (strcmp(nw,st)==0)
j=j++;
}}
getch();
}
| Is This Answer Correct ? | 68 Yes | 183 No |
What is const volatile variable in c?
int i=~0; uint j=(uint)i; j++; printf(“%d”,j);
what is the program to display your name in any color?
we have a 3litres jug and a 5 litres jug and no measures on them. using these two jugs how can we measure 4 litres of water?
How would you sort a linked list?
main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); } output?
What are Macros? What are its advantages and disadvantages?
here is a link to download Let_Us_C_-_Yashwant_Kanetkar
Are the expressions * ptr ++ and ++ * ptr same?
How to write a code for random pick from 1-1000 numbers? The output should contain the 10 numbers from the range 1-1000 which should pick randomly, ie ,for each time we run the code we should get different outputs.
Difference between strcpy() and memcpy() function?
I came across some code that puts a (void) cast before each call to printf. Why?