Home

Write C++ Program to Print Number Entered by User

Published on 21-Dec-2021 13:01:07
In this example, you'll learn to print the number entered by a user using C++ cout statement. Program : #include <iostream> using namespace std; int main() { int number; cout << "Enter an integer: "; cin >> number; cout << "You entered " << number; return 0; } Output : Enter an integer: 23 You entered 23 Explanation : This program asks the user to enter a number.... Read More

Write a program in C++ to print Hello World

Published on 21-Dec-2021 12:06:30
Program : To print hello world using C++ // Your First C++ Program #include int main() { std::cout << "Hello World!"; return 0; } Output : Hello World! Explanation: 1. // Your First C++ Program In C++, any line starting with // is a comment. Comments are intended for the person reading the code to better understand the functionality of the program. It is completely ignored by the C++ compiler. 2. #inclu... Read More

Write C Program to Find Smallest Element in Array in C Programming

Published on 20-Dec-2021 20:18:00
Program : Find Smallest Element in Array in C Programming #include <stdio.h> int main() { int a[30], i, num, smallest; printf("\nEnter no of elements :"); scanf("%d", &num); //Read n elements in an array for (i = 0; i < num; i++) scanf("%d", &a[i]); //Consider first element as smallest smallest = a[0]; for (i = 0; i < num; i++) { if (a[i] < smallest) { sm... Read More

Write C Program to Calculate Addition of All Elements in Array

Published on 20-Dec-2021 20:11:22
Program : Addition of All Elements of the Array #include <stdio.h> int main() { int i, arr[50], sum, num; printf("\nEnter no of elements :"); scanf("%d", &num); //Reading values into Array printf("\nEnter the values :"); for (i = 0; i < num; i++) scanf("%d", &arr[i]); //Computation of total sum = 0; for (i = 0; i < num; i++) sum = sum + arr[i]; //Printing of a... Read More

Write C Program to Delete duplicate elements from an array

Published on 19-Dec-2021 17:47:06
Program : To delete duplicate elements in an array #include <stdio.h> int main() { int arr[20], i, j, k, size; printf("\nEnter array size : "); scanf("%d", &size); printf("\nAccept Numbers : "); for (i = 0; i < size; i++) scanf("%d", &arr[i]); printf("\nArray with Unique list : "); for (i = 0; i < size; i++) { for (j = i + 1; j < size;) { if (arr[j] == arr[i])... Read More

Write a C program using pointers to read in an array of integers and print its elements in reverse order.

Published on 19-Dec-2021 17:39:45
#include <stdio.h> #include <conio.h> #define MAX 30 void main() { int size, i, arr[MAX]; int *ptr; clrscr(); ptr = &arr[0]; printf("\nEnter the size of array : "); scanf("%d", &size); printf("\nEnter %d integers into array: ", size); for (i = 0; i < size; i++) { scanf("%d", ptr); ptr++; } ptr = &arr[size - 1]; printf("\nElements of array in reverse order are :"); for (i = si... Read More

How to Implement Stack Operations Using Array using C

Published on 18-Dec-2021 18:27:23
Program for implementing a stack using arrays.It involves various operations such as push,pop,stack empty,stack full and display. #include <stdio.h> #include <conio.h> #include <stdlib.h> #define size 5 struct stack { int s[size]; int top; } st; int stfull() { if (st.top >= size - 1) return 1; else return 0; } void push(int item) { st.top++; st.s[st.top] = item; } int... Read More

How to find the nth highest salary in SQL ?

Published on 16-Dec-2021 16:52:22
This is how we can find the nth highest salary in SQL SERVER using TOP keyword: SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP N salary FROM Employee ORDER BY salary DESC ) AS temp ORDER BY salary This is how we can find the nth highest salary in MYSQL using LIMIT keyword: SELECT salary FROM Employee ORDER BY salary DESC LIMIT N-1, 1 ... Read More

How to insert multiple rows in SQL ?

Published on 16-Dec-2021 16:49:13
To insert multiple rows in SQL we can follow the below syntax: INSERT INTO table_name (column1, column2,column3...) VALUES (value1, value2, value3…..), (value1, value2, value3….), ... (value1, value2, value3); We start off by giving the keywords INSERT INTO then we give the name of the table into which we would want to insert the values. We will follow it up with the list of the columns, for which we would have to a... Read More