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 |
pick out the odd one out of the following a.malloc() b.calloc() c.free() d.realloc()
program for validity of triangle from 3 side
What is the output of below code? main() { static in a=5; printf("%3d",a--); if(a) main(); }
a=0; b=(a=0)?2:3; a) What will be the value of b? why b) If in 1st stmt a=0 is replaced by -1, b=? c) If in second stmt a=0 is replaced by -1, b=?
What is the heap?
What are header files and explain what are its uses in c programming?
What is the difference between pure virtual function and virtual function?
1.)how to find d most repeated word in a string? string ="how do you do"?? output should be do
1 Answers AAS, Nagarro, Vuram,
In C, What is the #line used for?
Is array name a pointer?
What is sizeof int in c?
How do you define a string?