Skip to main content

Posts

Showing posts from 2017

C programs QnA

Q. If sum of two integer is 14 and if one of them is 8 then find other integer. Ans: Well, this is very simple. Simply, one integer is 8 and sum of two integers is 14. So, we need to subtract the number 8 from their sum of 14 to get the second number. So, the second number is: 14 - 8 = 6 C-Program of this task Code---> #include<stdio.h> int main () { int num1 = 8 , num2 , sum = 14 ; num2 = sum - num1 ; printf ( "The second number is: %d" , num2 ); return 0 ; }

Multiplication of two Float numbers in C++ Language without and with Class

In this C++ program we will calculate the multiplication of two numbers(float) and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers(float). (i.e. 15.4,2.4 etc.) output: Multiplication of the given numbers(float) will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { float num1,num2,mul; cout << " \n      Enter a Number : " ; cin >>num1; cout << "\n      Enter another Number : " ; cin >>num2; mul=num1*num2; cout << "\n      The multiplication of the Numbers is : " << mul << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class multi { private : float x , y ; public : void get () { cout << "Enter two num...

Difference between two numbers(float) in C++ Language without and with Class

In this C++ program we will calculate the difference between the two numbers(float) and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15.6,65.7 etc.) output: Difference between the given numbers(float) will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { float num1, num2, difference; cout << " \n Enter a Number : " ; cin >>num1 ; cout << " \n Enter another Number : " ; cin >>num2 ; difference = num1 - num2 ; cout \n The Difference between the Numbers is : " <<difference <<endl ; system (" pause ") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class differ { private : float x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x ...

Sum of two float numbers in C++ without and with Class

In this C++ program we will calculate the sum of the two numbers(float) and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15.6,65.7 etc.) output: Sum of the given numbers(float) will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { float a,b,sum; cout << " \n Enter a Number : " ; cin >>a; cout << " \n Enter another Number : " ; cin >>b; sum=a+b; cout \n The sum of the Numbers is : " <<sum <<endl ; system (" pause ") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class sum { private : float x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp () { float c ; c = x + y ; cout << ...

Float division in C++ without and with Class

In this C++ program we will calculate the division between two numbers(float). The numbers will be taken from the user. input: Two numbers.(i.e : 9,56,548) output: After division the result will be printed on the screen. CODE----> #include<iostream> using namespace std; main() {    float num1, num2, div;    cout <<"       Please, Enter a Number  :  ";    cin >>num1;    cout <<" \n      Please, Enter another Number :  ";    cin >>num2;   div=num1/num2;    cout \n      The result is :  " <<div  <<" \n ";   system (" pause "); } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class div { private : float x , y ; public : void get () { cout <...

Calculate the sum up to N numbers using Array in C-Language

In this C -program we will calculate the sum upto 'N' numbers using array. The numbers will be taken from the user. input: 'N' numbers.(i.e : 9,56,548) output: The sum of the given numbers will be printed on the screen. CODE----> #include<stdio.h> #include<stdlib.h> main() { int arr[50],i,n,sum=0; printf("       How many numbers you want to enter ?\n "); scanf(" %d ",&n); printf ("       Please,Enter the numbers : "); for ( i=0 ; i<n ; i++ ) {       scanf (" %d ",&arr[i]); } for ( i=0 ; i<n ; i++ ) {      sum=sum+arr[i]; } printf (" \n      The sum of the given numbers is : %d\n ",sum); system (" pause "); } Don't just read, write it, run it..... RESULT :

Calculate sum of 5 numbers using Array in C-language

In this C -program we will scan the numbers using array and then we will calculate the sum of the given numbers, also using array. The numbers will be taken from the user. input: 5 numbers.(i.e : 5,6,9,56,548) output: The sum of the given numbers will be printed on the screen. CODE----> #include<stdio.h> #include<stdlib.h> main() { int arr[5],i,sum=0; printf ("       Enter Five numbers : "); for ( i=0 ; i<5 ; i++ ) {       scanf (" %d ",&arr[i]); } for ( i=0 ; i<5 ; i++ ) {      sum=sum+arr[i]; } printf (" \n      The sum of the given 5 numbers is : %d\n ",sum); system (" pause "); } Don't just read, write it, run it..... RESULT :

Scan and Print 5 Numbers Using Array in C-Language

In this C -program we will Scan and Print 5 numbers using Array. This is a simple Array program. The numbers will be taken from the user. input: 5 numbers.(i.e : 5,6,9,56,548) output: The given numbers by user will be printed on the screen. CODE----> #include<stdio.h> #include<stdlib.h> //This header file contains the system() function. main() { int arr[5],i; printf ("       Enter Five numbers : "); for ( i=0 ; i<5 ; i++ ) { scanf (" %d ",&arr[i]); } printf (" \n      You have Entered these following numbers : \n "); for ( i=0 ; i<5 ; i++ ) { printf ("       %d\n ", arr[i]); } system (" pause "); //this function is called for pause the screen. } Don't just read, write it, run it..... RESULT :

Hello World in PYTHON

In this PYTHON program we will print "Hello World !!!" in the screen. input: Null. output: "Hello World !!!" will be printed on the screen. CODE----> print (" Hello World !!!\n ") input (" Press, \"Enter\" to close the window.... ") #this line is used for holding the screen. ##Remove it, if getting an error. Don't just read, write it, run it..... RESULT :

Division in C++ Language(integer division) without and with Class

In this C++ program we will calculate the division between two numbers and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15,05 etc.) output: Devision between the given numbers will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { int a,b,div; cout << " \nEnter a Number : " ; cin >>a; cout << "\nEnter another Number : " ; cin >>b; div=a/b; cout << "\nThe result is : " <<a <<" / " <<b <<" = " << div << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class div { private : int x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp (...

Multiplication of two numbers in C++ Language without and with Class

In this C++ program we will calculate the multiplication of two numbers and print the result, in the screen. The two numbers will be taken from the user. input: Two numbers. (i.e. 15,05 etc.) output: Multiplication of the given numbers will be printed on the screen. CODE----> #include<iostream> using namespace std; main() { int a,b,mul; cout << " \nEnter a Number : " ; cin >>a; cout << "\nEnter another Number : " ; cin >>b; mul=a*b; cout << "\nThe multiplication of the Numbers is : " << mul << endl ; system ("pause") ; } Don't just read, write it, run it..... RESULT : With Class #include<iostream> using namespace std ; class multi { private : int x , y ; public : void get () { cout << "Enter two numbers : " ; cin >> x >> y ; } void disp () { int c ; c = x * y ; cout ...