1.

#include<iostream.h>

 

void main()

{

int i,sum;

int int-array[]={10,20,30,40,50};

sum-0;

for(i=0;i<5;i++)

 sum+=int-arra[i];

cout<<”Sum of elements of the array:”<<sum;

}

 

 

 

2. Write a program to declare an array of integers that can hold 10 values. Read the elements of the array from the user, and also display the contents in the reverse order.

 

#include<iostream.h>

 

void main()

{

 int arr[10];

int i;

for(i=0;i<10;i++)

cin>>arr[i];

 

for(i=9;i>=0;i--)

 cout<<arr[i]<<endl;

}

 

3. Write a program to read a sentence into an identifier called as word from the user. Using while loop and switch statements, display the count of vowels present in the given sentence.

 

#include<iostream.h>

void main()

{

char word[100]="The vowel count AEIOU aeiou";int i,cnt=0;

clrscr();

i=0;

while(word[i]!='\0')

{

switch(word[i])

{

case ‘a’:

case ‘A’:

case ‘e’:

case ‘E’:

case ‘I’:

case ‘I’:

case ‘o’:

case ‘O’:

case ‘u’:

case ‘U’:

   cnt++;

}

cout<<"Vowels:"<<cnt;

getch();

}

 

Hosted by www.Geocities.ws

1