CPP Practice Question
"My Name is Aarti Saindane"
- take two number as input from user and find out sum of this number then again find out square of result.
- take 3 number from user then find out greatest number among three.
- take input salary from user then increase 20% of salary and print total salary of employee.
- take input 5 subject of marks and find out total Marks and percentage and average ?
- take two number from user and swap it without temp in cpp.
- write a program in c++ to accept Radius(in cms) of a circle from the user ,calculate and display (a) Circumference of the circle (b) Area of the circle.
- Write a program in C++ to take length and width as input from user to find the Area and Perimeter of a Rectangle.
- Write a C++ program to input customer ID, name, and electricity unit consumed by the user and calculate total electricity bill according to the given condition:
- For first 50 units Rs. 0.50/unit
- For next 100 units Rs. 0.75/unit
- For next 100 units Rs. 1.20/unit
- For unit above 250 Rs. 1.50/unit
- An additional surcharge of 20% is added to the bill
- Write a program in C++ to check whether a number is positive, negative or zero.
- Write a program in c++ to find & display sum of 6+12+18+….N term and 4+10+16+…N Term , n to be entered by the user.
- Write a program to display a range of alphabets in reversed & alternative order .
- write a cpp program to enter marks of five subjects and calculate the Total, Percentage, and find Grade according to the following Condition:.
- Percentage >= 90% : Grade A
- Percentage >= 80% : Grade B
- Percentage >= 70% : Grade C
- Percentage >= 60% : Grade D
- Percentage >= 40% : Grade E
- Percentage < 40% : Grade F
- write a cpp programm to take input absent days and find out Total Fine fees accourding to below Condition.
- week pay 5 rs per day
- week pay 10 rs per day
- week pay 15 rs per day
- Rest 20 rupees per days.
- Write a cpp program to find Fibonacci Series up to n number of terms.
The Fibonacci sequence is like this,
0, 1, 1, 2, 3, 5, 8, 13, 21.....n term.
- take input any number and find out number is Odd or Even in cpp.
- Write a cpp program to check you are eligible for vote or not/drive or not.
- Write a cpp program to check number is prime or not ?
- Write a cpp program to check number armstrong or not ?
- Write a Program to Check Whether a Number Is a Palindrome or Not.
- Write a program to accept an alphabet and Check its vowel or consonant.
- Wap Accept 1 to 7 number and display their respective day name.
- Wap Menu driven programm for all arithmetic operation by switch case
- Wap to enter a number then print their English word.
- take input any alphabet and check alphabet is vowel or consonant by switch case.
- Write cpp programm read a sentence and find out number of word.
- Write a menu driven program which accepts a user’s choice to calculate and display area of any of the following shapes ,with reqired inputs entered by the user for the desired shape:
a)The menu should keep reappearing till the user chooses an option Exit to exit the program execution
b) a.Area of a rectangle b. Area of a triangle c. Area of Circle
- take input amount and find out number of notes in cpp?
- display 1 to 10 number using for loop,while loop and do while loop.
- take number as input from the user and generate table ?
- find out total sum between 1 to 50 number using loop?
- Write a program in C++ to display the numbers in reverse order.
Example : Number : 1345
The number in reverse order is : 543
- Write a C++ program to take input 10 number in two array and find out addition of two array ?
- Take 10 integer inputs from user and store them in an array. Now, copy all the elements in another array but in reverse order.
- Write a C++ program to take input 10 number in array and find sum of all number and product ?
- Write a C++ program to take input 5 number in array and find out square of all number ?
- Take 10 integer as inputs from user in array and find out all even number and all odd number?
- Write a C++ program to take input 5 subject of marks in array and find out total marks and percentage ?
- Write a C++ program to take 10 number as input from user in array and find out the largest element of array?
- Write a C++ program to take 10 number as input from user in array and find out the Smallest element of array?
- Write a C++ program to take 10 number as input from user in array and find out the Second largest element of array?
- Write a C++ program to take 10 number as input from user in array and find out the Second Smallest element of array?
- Write a C++ program to take 10 number as input from user in array and then take any number as input in another variable then search this number is exist or not.
Q 1. write a cpp programm to take input your name and print like below format.
#include<iostream>
using namespace std;
int main()
{
char name[50];
cout<<"Enter your name "<<endl;
cin>>name;
cout<<"my name is "<<name;
return 0;
}
Q 4 . take input salary from user then increase 20% of salary and print total salary of employee.
#include <iostream>
using namespace std;
int main()
{
int salary, total_salary , per;
cout<<"Enter Employee Salary ? = ";
cin>>salary;
per= salary*20/100;
total_salary = salary+per;
cout<<"<==============================>\n";
cout<<"Total salary of Employee is = "<<total_salary;
return 0;
}
Q 7. write a program in c++ to accept Radius(in cms) of a circle from the user ,calculate and display (a) Circumference of the circle (b) Area of the circle.
#include <iostream>
using namespace std;
int main()
{
int radius;
float area,Circumference, PI=3.14;
cout<<"Enter Radius of Circle ? = ";
cin>>radius;
area= PI*radius*radius; // A=pr2
Circumference = 2*PI*radius; // C=2pr
cout<<"<==============================>\n\n";
cout<<"Area of Circle is "<<area <<" cm"<<endl;
cout<<"Circumference of Circle is "<<Circumference<<" cm";
return 0;
}
Q 8 Write a C++ program to input customer ID, name, and electricity unit consumed by the user and calculate total electricity bill
#include <iostream>
using namespace std;
int main()
{
int units;
float total_bill;
cout<<"Enter Consumed Units ? = ";
cin>>units;
if(units>=1 && units <=50)
{
total_bill = units *0.50;
}
else if(units >50 && units <=150)
{
total_bill= units *0.75;
}
else if(units >150 && units <=250)
{
total_bill= units *1.20;
}
else
{
total_bill=units*1.50;
}
cout<<"<================================>\n";
cout<<"Total Electricity bill is = "<<total_bill<<" RS.";
return 0;
}
Q .Write a C++ program to check number is armstrong or not ?
#include<iostream>
using namespace std;
int main()
{
int num,reminder,temp,sum_of_q=0 ;
cout<<"Enter a Number";
cin>>num;
temp=num;
while(num>0)
{
reminder=num%10;
num=num/10;
sum_of_q=sum_of_q+(reminder*reminder*reminder);
}
if(temp==sum_of_q)
{
cout<<"its Armstrong Number";
}
else
{
cout<<"its Not Armstromg Number";
}
}
32. Write a C++ program that makes a pattern such as bellow.
#include <iostream>
using namespace std;
int main()
{
int i,j, count=1, n;
for(i=1;i<5;i++)
{
for(j=1;j<=i;j++)
{
cout<<count<<" ";
count++;
}
cout<<endl;
}
return 0;
}
35.Write a C++ program that makes a pattern such as bellow.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
#include<iostream>
using namespace std;
int main ()
{
int i,j,k,n;
cout<<"enter the row size = ";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=n-i;j>=1;j--)
{
cout<<" ";
}
for(k=1;k<=i;k++)
{
//cout<<"* " ;
cout<<i<<" " ;
// cout<<k<<" " ;
}
cout<<endl;
}
return 0;
}
Find Second Greatest Number in cpp
#include<iostream>
using namespace std;
int main()
{
int i, num[10], large, slarge;
cout<<"Enter 10 Array Elements: ";
for(i=0; i<10; i++)
cin>>num[i];
large = num[0];
for(i=0; i<10; i++)
{
if(large<num[i])
large = num[i];
}
slarge = num[0];
for(i=0; i<10; i++)
{
if(slarge<num[i])
{
if(num[i]!=large)
slarge = num[i];
}
}
cout<<" \nLargest Element="<<large;
cout<<" \nSecond Largest Element="<<slarge;
cout<<endl;
return 0;
}
Find the second smallest element using a for loop
#include<iostream>
using namespace std;
int main()
{
int i, num[10], small, ssmall;
cout<<"Enter any 10 elements for the array: ";
for(i=0; i<10; i++)
cin>>num[i];
small = num[0];
for(i=0; i<10; i++)
{
if(small>num[i])
small = num[i];
}
ssmall = num[0];
for(i=0; i<10; i++)
{
if(ssmall>num[i])
{
if(num[i]!=small)
ssmall = num[i];
}
}
cout<<"\nSmallest element = "<<small;
cout<<"\nSecond smallest element = "<<ssmall;
cout<<endl;
return 0;
}
Last Updated on : 20th Dec 2024 16:32:55 PM
Latest Update
- JavaScript Interview Question MongoDb Command Curd Operation Node MonogoDb Express EJSC Practice Question Example Data Structure with CPPjava practice questionCurd operation with localstorage in javascriptComplete curd operation in react with json server and axios and router-domCPP Practice Question React Interview Question Java Pattern Program