Print First N Terms of Series 0.25, 0.5, 0.75 in Fraction Representation

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

229 Views

Input N which is equivalent to the number till where series should be printedInput : N=5 Output : 0 ¼ ½ ¾ 1AlgorithmSTART Step 1 -> declare start variables as int num , den, i, n Step 2 -> input number in n Step 3 -> Loop For from i to 0 and i End For Loop STOPExample#include int main(int argc, char const *argv[]) {    int num, den;    int i, n;    printf("Enter series limit");    scanf("%d", &n); //Till where the series will be starting from zero    for (i = 0; i < n; i++) { ... Read More

Setjmp and Longjmp in C

Smita Kapse
Updated on 30-Jul-2019 22:30:26

3K+ Views

In this section, we will see what are the setjump and longjump in C. The setjump() and longjump() is located at setjmp.h library. The syntax of these two functions is like below.setjump(jmp_buf buf) : uses buf to store current position and returns 0. longjump(jmp_buf buf, i) : Go back to place pointed by buf and return i.These are used in C for exception handling. The setjump() can be used as try block, and longjump() can be used as throw statement. The longjump() transfers control the pointe which is pointed by setjump().Here we will see how to print a number 100 ... Read More

Convert Time from 12-Hour to 24-Hour Format in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:26

1K+ Views

This is a C++ program to convert time from 12 hour to 24 hour format.AlgorithmBegin    In main(),    If median = pm       Check if entered hours is less than 12          Then add 12 to hours and print the time in 24 hours format.       Check if entered hours is equal to 12          Then print “00” as hours and print the time in 24 hours format.    Else If median=am       Check if entered hours is less than 12          Then print ... Read More

Check Installed MongoDB Version Using Command Line

Smita Kapse
Updated on 30-Jul-2019 22:30:26

12K+ Views

First open the CMD and then reach the BIN directory of MongoDB. The screenshot to open CMD prompt is as follows.Above we have reached the RUN dialog by pressing START and then typing RUN and ENTER.Now, type CMD and press OK button to get the command line. The screenshot is as follows −Reach the BIN directory of MongoDB. Following is how to reach the BIN −Use the query mongo –version. The screenshot of the query is as follows −Above displays that our current MongoDB version is v4.0.5.

Combine BorderLayout, GridLayout, and FlowLayout in Java Swing

Anvi Jain
Updated on 30-Jul-2019 22:30:26

1K+ Views

Here, we have set panels with BorderLayout, GridLayout and FlowLayout. Within the panels, we have created components such as Button, ComboBox, etc. The following is an example to combine layouts in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       JButton btnA = new JButton("Button1 (Left)");       JButton btnB = new JButton("Button2 (Right)");       JButton btnC = new JButton("Button3 (Left)");       JButton btnD = new JButton("Button4 (Right)");       ... Read More

Comparison of Exception Handling in C++ and Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

330 Views

The exception handling feature is present almost any object oriented languages nowadays. In C++ and Java also we can get this kind of feature. There are some similarities between exception handling in C++ and exception handling in Java, like in both languages we have to use the try-catch block. Though there are some difficulties also. These are like below −In C++, we can throw any type of data as exception. Any type of data means primitive datatypes and pointers also. In Java we can only throw the throwable objects. Subclasses of any throwable class will also be throwable.Example Live Demo#include ... Read More

What are Enumerations in Java and How to Retrieve Values from an Enum

Venkata Sai
Updated on 30-Jul-2019 22:30:26

650 Views

Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.You can define an enumeration using the keyword enum followed by the name of the enumeration as −enum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }Just like arrays, the elements/constants in an enumeration are identified using numbers starting from 0 in the above example the days are identified using numbers as shown in the following illustration −Retrieving values from an enumYou can retrieve all the ... Read More

HTML DOM Input Email Multiple Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

229 Views

The HTML DOM Input Email multiple property returns/sets if input Email should accept multiple emails or not.SyntaxFollowing is the syntax −Returning reference to the multiple objectinputEmailObject.multipleSet multiple property to boolValueinputEmailObject.multiple = boolValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailstrueIt defines that the input email accepts multiple entries.falseIt defines that the input email is not accepying multiple emails and it is also the default value.ExampleLet us see an example of Input Email multiple property − Live Demo Input Email multiple    form {       width:70%;       margin: 0 auto;       text-align: center;   ... Read More

Truncate Floating Point Numbers in C Language

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

2K+ Views

Here we will see three functions. These functions are trunc(), truncf() and the truncl(). These functions are used to convert floating point values into truncated form.The trunc() FunctionThis function is used to truncate double type value. And return only the integer part. The syntax is like below.double trunc(double argument)Example#include #include main() {    double a, b, x, y;    x = 53.26;    y = 75.86;    a = trunc(x);    b = trunc(y);    printf("The value of a: %lf", a);    printf("The value of a: %lf", b); }OutputThe value of a: 53.000000 The value of a: 75.000000The ... Read More

C++ Program to Print Happy Birthday

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

7K+ Views

This is a C++ program to print Happy Birthday.AlgorithmBegin    Take a str1 which takes the next character of our desired ouput like for H it will be G.    Assign the string to a pointer p.    Make a while loop till *p != NULL.       Go next character of the string print it and after that go the nextposition of string.    Print the result. EndExample#include using namespace std; main(){    char str[]="G`ooxAhqsgc`x",*p;    p=str;    while(*p!='\0')       ++*p++;    cout

Advertisements