Upcoming SlideShare
×

# CBSE Class XI Programming in C++

957 views

Published on

CBSE Class XI Programming in C++

Published in: Education, Technology, Spiritual
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
957
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
67
0
Likes
1
Embeds 0
No embeds

No notes for slide

### CBSE Class XI Programming in C++

1. 1. The Programs
2. 2. Sum Of MatricesSum Of Matrices
3. 3. Product Of Matrices cout<<"Enter second matrix rowcout<<"Enter second matrix row wise";wise"; for(i = 0; i<p; ++i)for(i = 0; i<p; ++i) for(j = 0; j<q; ++j)for(j = 0; j<q; ++j) cin>>B[i][j];cin>>B[i][j]; cout<<“product of the givencout<<“product of the given two matrix is : “;two matrix is : “; for(i = 0; i<m; ++i)for(i = 0; i<m; ++i) { cout<<“n”;{ cout<<“n”; for(j = 0; j<n; ++j)for(j = 0; j<n; ++j) { C[i][j] = 0;{ C[i][j] = 0; C[i][j] = C[i][j] + A[i][k] * B[k]C[i][j] = C[i][j] + A[i][k] * B[k] [j];[j]; cout<< C[i][j] << “ “;cout<< C[i][j] << “ “; }} }} }} elseelse cout<<“n the matrices are notcout<<“n the matrices are not compatible for multiplication “;compatible for multiplication “; getch();getch(); }}
4. 4. Linear Search
5. 5. Palindrome(string)
6. 6. Stats of text #include<iostream.h> #include<conio.h> #include<process.h> void textstat( char str[], int &lc, int &wc, int &cc); void main() { clrscr(); char str[255] = “ Hi how are you !! ”; int lc, wc, cc; cout<<“n Enter any string (~ to terminate) : “; cin.getline(str, 255,’~’) textstat(str, lc, wc, cc); cout<< “number of lines in the string are: “<< lc; cout<< “number of words in the string are: “<< wc; cout<< “number of characters in the string are: “<< cc; getch(); } int wordcount(char str[]) { int count = 1; for (int i = 0; str[i] ‘0’; ++i) { if (str[i] == ‘i’ || str[i] == ‘n’) {count ++; while (str[i] ==‘ ‘) i++; } if (str[i]==‘0’) i--; } return count; } int charcount(char str[]) int count = 0; for (int i = 0; str[i] ‘0’; ++i) count++; return count; } int linecount(char str[]) { int count = 1; for (int i = 0; str[i] ‘0’; ++i) if(str[i]==‘n’) count++; return count; } void textstat( char str[], int &lc, int &wc, int &cc) { lc = linecount(str); wc = wordcount(str); cc = charcount(str); }
7. 7. Nested structures#include<iostream.h> #include<conio.h> #include<stdio.h> struct addr { int houseno; char area[25]; char city[25]; char state[25]; }; struct emp { int empno; char name[25]; char desig[25]; addr address; float basic; } worker; int main () { clrscr(); cout<<" n Enter employee number:" cin>>worker.empno; cout<<" n Enter name:" gets(worker.name); cout<<" n Enter Designation:" gets(worker.desig); cout<<" n Enter House no. :" gets(worker.address.houseno); cout<<" n Enter Area" gets(worker.address.area); cout<<" n Enter city getsworker.address.city); cout<<" n Enter state" gets(worker.address.state); cout<<" n Enter Basic pay " cin>>worker.basic; return0; }
8. 8. Student’s Result#include<iostream.h> #include<conio.h> #include<stdio.h> struct student { int rollno; char name[25]; float marks; char grade; }; student learner; void main () { clrscr(); cout<<" n Enter roll number:" cin>>learner.rollno; cout<<" n Enter name:" gets(learner.name); cout<<" n marks in 5 subjects:" for (int i = 0;i < 5 ; ++i) { cout<<"Subject"<< i + 1 <<": "; cin>>learner.marks[i]; } float avg, total = 0; for (int i = 0;i < 5 ; ++i) total += sum[i]; avg = total/ 5; if (avg < 50) learner.grade = 'F'; else if (avg < 60) learner.grade = 'C'; else if (avg < 80) learner.grade = 'B'; else lerner.grade = 'A' cout<<" n Student's Result :" cout<<" n roll number :"<<learner.rollno; cout<<" n Name :' puts(learner.name); cout<<" n Total marks :"<< total; cout<<" n Grade :"<<learner.grade <<endl; } cout<<" n Enter Basic pay " cin>>worker.basic; return 0; }
9. 9. Equality of strings
10. 10. The later Date #include<iostream.h>#include<iostream.h> #include<conio.h>#include<conio.h> #include<process.h>#include<process.h> #include<stdio.h>#include<stdio.h> date later( dateS1, dateS2);date later( dateS1, dateS2); void main()void main() { clrscr();{ clrscr(); struct date { int day;struct date { int day; int month;int month; int year;int year; }d1, d2;}d1, d2; cout<<"enterfirst date";cout<<"enterfirst date"; cout<<"enterday";cout<<"enterday"; gets(d1.day);gets(d1.day); cout<<"entermonth";cout<<"entermonth"; gets(d1.month);gets(d1.month); cout<<"enteryear";cout<<"enteryear"; gets(d1.year);gets(d1.year); cout<<"n";cout<<"n"; cout<<"entersecond date";cout<<"entersecond date"; cout<<"enterday";cout<<"enterday"; gets(d2.day);gets(d2.day); cout<<"entermonth";cout<<"entermonth"; gets(d2.month);gets(d2.month); cout<<"enteryear";cout<<"enteryear"; gets(d2.year);gets(d2.year); date later(date S1, date S2)date later(date S1, date S2) getch();getch(); }} date later(date S1, date S2)date later(date S1, date S2) {{ if (S2.year> S1.year)if (S2.year> S1.year) cout<< S2;cout<< S2; else if (S1.year> S2.year)else if (S1.year> S2.year) cout<< S1;cout<< S1; else if (S1.month > S2.month)else if (S1.month > S2.month) cout<< S1;cout<< S1; else if (S1.month < S2.month)else if (S1.month < S2.month) cout<< S2;cout<< S2; else if (S2.day > S1.day)else if (S2.day > S1.day) cout<< S2;cout<< S2; elseelse cout<< S1;cout<< S1; }}