C program to find area and Perimeter of Rectangle-1

C program to find area and Perimeter of Rectangle

C program to find area and Perimeter of Rectangle #include<stdio.h> int main() { int length,wight,area=0; printf(“Enter a length and wight:”); scanf(“%d %d”,&length,&wight); area=length*wight; printf(“area of rectangle is:%d”,area); return 0; } C program to find area and Perimeter of Rectangle This code is a simple C program that calculates the area of a rectangle based on … Read more

C Program to Calculate Cube of a Number || practice coding

C Program to Calculate Cube of a Number

How to write a C Program to Calculate Cube of a Number using Functions with an example? C Program to Calculate Cube of a Number #include<stdio.h> void main () { int i,cube; scanf(“%d”,&i); for(int i=1;i<=5;i++){ cube=i*i*i; printf(“\nnumber is %d and cube of the %d is :%d”,i,i,cube); } } C Program to Calculate Cube of a … Read more

Write a program in C to read 10 numbers from the keyboard and find their sum and average

10 numbers from the keyboard and find their sum and average

Write a program in C to read 10 numbers from the keyboard and find their sum and average Solution in C: #include<stdio.h> void main() { int i,n,sum=0 ;double aver=0; printf(“enter the number:”); scanf(“%d”,&n); for(i=1;i<=10;i++){ sum=sum+i; aver=sum/(double)10; } printf(“The sum of 10 no is :%d\n”,sum); printf(“The Average is :%lf”,aver); return 0; } This code is a … Read more

Write a program sum of first n natural numbers in C.

sum of first n natural numbers in c

Write a program sum of first n natural numbers in C. #include<stdio.h> void main () { int i,n ,sum= 0; scanf(“%d”,&n); printf(“The first 7 natural is:”,n); for(int i=1;i<=7;i++) { printf(“%d “,i); sum=sum+i; } printf(“\nThe Sum of Natural Number upto 7 terms : %d”,sum); return 0; } Write a program in C to display the first … Read more

Write a program in C to display the first 10 natural numbers.

Write a program in C to display the first 10 natural numbers

Example 1.Write a program in C to display the first 10 natural numbers. #include<stdio.h> void main () { int i,n; scanf(“%d”,&n); printf(“The first 10 natural numbers are: “,n); for(int i=1; i<=n;i++) { printf(“%d “,i); } } When you run this code, it will output the numbers 1 through 10 separated by spaces. The loop will … Read more

How do you add one object to another object in CPP?-3

How do you add one object to another object in CPP

How do you add one object to another object in CPP? In C++, objects are created using classes. A class is a user-defined data type that defines a blueprint for creating objects. One of the most common operations performed on objects is adding one object to another object. This operation is known as object addition, … Read more

How to use a string in Object-Oriented Programming Cpp

How to use a string in Object-Oriented Programming Cpp

How to use a string in Object-Oriented Programming Cpp Are you new to object-oriented programming and wondering how to use a string in C++? Look no further. In this comprehensive guide, we will cover everything you need to know about using a string in object-oriented programming. How to Use a String in Object-Oriented Programming C++ … Read more

How to Sum Two Numbers in Object-Oriented Programming in C++

How to Sum Two Numbers in Object-Oriented Programming in C++

How to Sum Two Numbers in Object-Oriented Programming in C++ Object-oriented programming is a powerful programming paradigm that provides numerous benefits, including code reusability, encapsulation, and inheritance. One common task in object-oriented programming is the addition of two numbers. In this article, we will discuss how to sum two numbers in object-oriented programming in C++. … Read more

How to create a class in cpp?

How to create a class in cpp

How to create a class in cpp? #include<iostream> using namespace std; class myclass{ public: int name(int a,int b); //this is function }; int myclass::name(int a,int b) //This is a member function { if(a>b){ cout <<a; } else { cout<<b; } return 0; } int main() { myclass obj; // myclass object is obj obj.name(30,50); //a=30,b=50 … Read more

Learn C++ Classes: Definition, Examples, and How to Use Them-1

C++ Class

Learn C++ Classes: Definition, Examples, and How to Use Them If you’re new to programming, understanding object-oriented programming can seem daunting. However, once you understand the basics, you can easily create your own classes in C++. In this article, we’ll walk you through the steps of creating a class in C++. What is a Class? … Read more