You are on page 1of 3

PROGRAM CODE: #include<iostream.h> #include<conio.

h> void main() { clrscr(); const int size=3; float sales[size], avg=0, total=0; for (int i=0;i<size;i++) { cout<<Enter sales made on day <<i+1<<:; cin>>sales[i]; total+=sales[i]; } avg=total/size; cout<<\n Total sales = <<total<<\n; cout<<Average sales = <<avg<<\n; getch(); }

SAMPLE INPUT & SAMPLE OUTPUT: Enter sales made on day 1: 10000 Enter sales made on day 2: 20000 Enter sales made on day 3: 30000 Total sales = 60000 Average sales = 20000

PROGRAM CODE: #include<iostream.h> #include<conio.h> int main() { float large(float arr[],int n); char ch; int i; float amount[50],big; for(i=0;i<50;i++) {cout<<\nEnter element no <<i+1<<\n; cin>>amount[i]; cout<<\nWant to enter more ?(y/n)\n; cin>>ch; if(ch!=y) break; } if(i<50) i++; big=large(amount,i); cout<<\nThe largest element of the array is:<<big<<\n; getch(); return 0; } float large(float arr[],int n) {float max=arr[0]; for(int j=1;j<n;j++) {if (arr[j]>max) max=arr[j]; } return(max); } SAMPLE INPUT AND OUTPUT: Enter element no 1 5 Want to enter more ?(y/n) y Enter element no 2 33 Want to enter more ?(y/n) y Enter element no 3 13 Want to enter more ?(y/n) n The largest element of the array is : 33

PROGRAM CODE: #include<iostream.h> #include<conio.h> int main() { clrscr(); char string[80],c; cout<<"Enter string(max. 79 char):"; cin.getline(string,80); for(int len=0;string[len]!='\0';len++); int i,j,flag=1; for(i=0,j=len-1;i<len/2;i++,j--) {if(string[i]!=string[j]) { flag=0; break; } } if(flag) cout<<"It is a palindrome.\n"; else cout<<"It is not a palindrome.\n"; getch(); return 0; } SAMPLE INPUT & OUTPUT: Enter string(max. 79 char):radar It is a palindrome.

You might also like