Posts

Featured post

-Write C program to find even and odd number using macro

-Write C program to find even and odd number using macro #include<stdio.h> #define number(n)((n%2==0)?1:0) int main() { int num; printf("enter any number"); scanf("%d",&num); if(number(num)) printf("number is even"); else printf("number is odd"); return 0; } ***************************Output*********************** amr@amrj-virtual-machine:~$ gccevenodd.c amr@samr-virtual-machine:~$ ./a.out enter any number 2 number is evensmj@amr-virtual-machine:~$

Write a c++ program to find Maximum of Three using parameterized Constructor.

//Maximum number using parameterized constructor  #include<iostream> using namespace std; class temp { int c; public: temp(int a,int b,int c) { if(a>b && b>c) { cout<<"maximum number is :"<<a; } else if(b>c) { cout<<"maximum number is "<<b; } else { cout<<"maximum number is"<<c; } } }; int main() { int a,b,c; cout<<"Enter the value:"; cin>>a>>b>>c; temp obj(a,b,c); return 0; } Out Put ******************************************************************** Enter the value:53 2 1 maximum number is :53 -------------------------------- Process exited after 5.656 seconds with return value 0 Press any key to continue . . . ************************************************************************

Write a C progrming To Calculate & Print Arithmetic Mean and Harmonic Mean.

  Write a C progrming  To Calculate & Print Arithmetic Mean and Harmonic Mean. To Calculate & Print Arithmetic Mean and Harmonic Mean. #include<stdio.h> void main() { floata,b; floatam,hm; printf("Enter the value of a"); scanf("%f",&a); printf("Enter the value of b"); scanf("%f",&b); am=(a+b)/2; printf("arithmetic mean=%f",am); hm=2/(1/a+1/b); printf("\n"); printf("harmonic mean=%f",hm); printf("\n"); } OUTPUT :- Amr@Amr-virtual-machine: ~ $ gcc slip1a.c Amr@Amr-virtual-machine:~$ ./a.out Enter the value of a 120 Enter the value of b 20 arithmeticmean= 70.0000 harmonic mean= 34.285713

Write a C Program to accept an integer and check if it is Even or Odd.

C Program to Check Even or Odd Number 🖥️ C Program to Check Even or Odd Number Below is a simple C program that checks whether a given number is even or odd. 📜 Source Code: #include <stdio.h> void main() { int num; printf("Enter number: "); scanf("%d", &num); if (num % 2 == 0) { printf("Number is even"); } else { printf("Number is odd"); } } 🖥️ Output: amr@amr-virtual-machine:~$ gcc slip6a.c amr@amr-virtual-machine:~$ ./a.out Enter number: 12 Number is even 🔹 Explanation: The program takes an integer input from the user. It checks whether the number is divisible by 2 using the modulus (%) operator. If the remainder is 0, it prints " Number is even ", otherwise, it prints " Number is odd ". 📌 Steps to Compile and Run: Save the file as slip6a.c . Open a terminal and navigate to the file location....

Write a c++ program to find the Function overloading example in c++(Addition, Subtraction,Multiplication).

A C++ Program To calculate the example of function overloading: #include<iostream> using namespace std; int fun(); int fun(int a,int b); int fun(int a); int fun() { int a,b; cout<<" Enter the three values:"; cin>>a>>b; cout<<"\n Sum is"<<a+b; return 0; } int fun(int a,int b) { cout<<"\n Subtraction  is:"<<a-b; return 0; } int fun(int a) { cout<<"\n Multiplication is same values:"<<a*a; return 0; } int main() { fun(); fun(10,5); fun(4); return 0; }  Out Put:-  Enter the three values:5 6  Sum is11  Substraction is:5  Multipliaction is same values:16 -------------------------------- Process exited after 3.722 seconds with return value 0 Press any key to continue . . .

Stack in Data structure

      Stack Definition:           Amreshtechknowledge.blogspot.com Stack is a order collection of homogeneous data elements where the insertion and deletion operation take place only one end that is called Stack. It is a LIFO (Last in First out) Technique.  It is a Abstract Data type. The position of stack where the operation is perform is called TOS(Top of Stack).                                                    Stack is Basically there are two operation. Push:-This is a insert or adding element in a stack i.e is called Push. Pop:-This is a delete or remove the element of stack is called POP.       Insert and delete   a specific number in stack by using push() and pop() #include<stdio.h> struct Node {    int data...