Assignment C++

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Assignment C++ as PDF for free.

More details

  • Words: 1,098
  • Pages: 13
Last program (i.e. 12th) is incorrect // A program to check wether the entered number is even or odd #include #include void main () { clrscr(); int num; cout<<"\n Enter a number to check wether it is even or odd : "; cin>>num; if (num%2==0) cout<<"\n The entered number "<
// A program to check wether the entered number is positive or negative #include #include void main() { clrscr(); int num; cout<<"\n Enter a number to check wether it is a positive or negative number : "; cin>>num; if(num>0) cout<<"\n Entered number "<
// A program for arithmetic operation using switch case(+ , - ,, * , / ) #include #include void main () { clrscr(); char s; float a , b , c; cout<<"\n Enter two numbers :" ; cin>>a>>b; cout<<"\n Enter the operation symbol ( + , - , * , / ) : "; cin>>s; switch (s) { case '+' : c=a+b; break; case '-' : c=a-b; break; case '*' : c=a*b; break; case '/' : c=a/b; break; default : cout<<"\n Invalid Option . "; break; } cout<<"\n Result : "< #include void main () { clrscr(); int num , cnum , rnum=0 ; cout<<"\n Enter a number to find its reverse : "; cin>>num; cnum=num; do { rnum=( rnum*10) + cnum%10 ; cnum=cnum/10 ; } while (cnum!=0) ; cout<<"\n Reverse number of "<
//A program to swap the entered number using function #include #include void swap (); void main() { clrscr(); swap(); getch(); } void swap() { int a, b; cout<<"\n Enter two numbers : \n\n A = : "; cin>>a; cout<<"\n B = : "; cin>>b; a=a+b; b=a-b; a=a-b; cout<<"\n Swaped numbers are : \n\n A = : "<
// A program to check wether the entered number is palindrome or not without using string. #include #include void main () { clrscr(); int num , cnum , rnum=0 ; cout<<"\n Enter a number to check wether its a palindrome or not : "; cin>>num; cnum=num; do { rnum=( rnum*10) + cnum%10 ; cnum=cnum/10 ; } while (cnum!=0) ; if (num == rnum) cout<<"\n Enterd number "<
// A program to calculate the sum of two matrices of order m * n #include #include void main () { clrscr(); int i, j, m , n, a[50][50] , b[50][50], c[50][50]; cout<<"\n Enter order of the matrices (less than 50*50) m*n : \n m = "; cin>>m; cout<<"\n n = "; cin>>n; cout<<"\n Enter the elements of matrix A of order "<<m<<"*"<>a[i][j]; } } cout<<"\n Enter the elements of matrix B of order "<<m<<"*"<>b[i][j]; } } cout<<"\n Entered elements of matrix A of order "<<m<<"*"<
cout<<endl; } for (i=0; i<m; i++) //For Calculating sum of two matrices { for (j=0; j
// A program to search an element in an array #include #include void main () { clrscr(); int a[100], n, s; cout<<"\n Enter lenghts of array (max 100) : "; cin>>n; cout<<"\n Enter the "<>a[i]; cout<<"\n Entered Array is : \n "; for (i=0; i>s; int b=0; for(i=0 ; i
//A program to calculate simple interest n times #include #include void main() { clrscr(); int n; float p, r, t, si, a ; cout<<"\n Enter the number of times you want to calculate the simple interest : "; cin>>n; for (int i=0 ; i>p; cout<<"\n Enter rate of interest (in %) : "; cin>>r; cout<<"\n Enter time priod ( in years ) : "; cin>>t; si=(p*r*t)/100; // formula for si a=p+si; // formula for total amount cout<<"\n\n Simple Interest = "<<si; cout<<"\n\n Total Amount = "<
// A program to calculate sum of odd numbers between 1 to 100 #include #include void main() { clrscr(); int s=0, n=1, i; do // To calculate sum { s=s+n; n=n+2; } while ( n<100) ; cout<<"\n Sum of all the odd numbers between 1 to 100 is : "<<s; getch(); }

// A program to insert an array and print it in reverse order #include #include void main () { clrscr(); int a[100], n; cout<<"\n Enter lenghts of array (max 100) : "; cin>>n; cout<<"\n Enter the "<>a[i]; cout<<"\n Entered Array is : \n "; for (i=0; i=0 ; i--) // for displaying it reverse order cout<
// A program to find reverse of entered number using an array #include #include void main () { clrscr(); int n, c, r=0, a[10]; cout<<"\n Enter a number : "; cin>>n; c=n; for(int i=1 ; c!=0; i++) { a[i]=c%10; c=c/10; } do { r=((r*10)+a[i]); i--; } while (i!=0) ; cout<<"\n The reverse of number "<

Related Documents

Assignment C++
November 2019 13
C # Assignment
December 2019 24
C-lab-assignment-1
July 2020 8
Assignment+2 C++
May 2020 10
C++ Assignment 1.docx
April 2020 16
C Assignment Sheet
November 2019 12