Q:- Write a program in C# that take a sentence as input, and show the number of "a" used in the sentence???
Ans;- using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
string name;
int counter = 0;
int i;
name = Console.ReadLine();
for ( i=0; i <name.Length; i++)
{
if (name[i] == 'a')
{
counter++;
}
}
Console.WriteLine(counter);
Console.ReadLine();
}
}
}
Ans;- using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
string name;
int counter = 0;
int i;
name = Console.ReadLine();
for ( i=0; i <name.Length; i++)
{
if (name[i] == 'a')
{
counter++;
}
}
Console.WriteLine(counter);
Console.ReadLine();
}
}
}
No comments:
Post a Comment