String concaination program using pointers in C?
#include<stdio.h>
#include<conio.h>
void main()
{
char a[5][10];
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("enter %d string",i+1);
scanf("%s",&a[i]);
}
for(i=0;i<5;i++)
{
printf("\n%s",a[i]);
}
getch();
}
Write a program that accepts a number and output its equivalent in words?
/*mycfiles.wordpress.com
program to convert digits to character*/
#include
#include
void main()
{
int a[5],i,n;
clrscr();
cout<<"Enter the Value";
cin>>n;
for(i=4;i>=0;i--)
{
a[i]=n%10;
n=n/10;
}
for(i=0;i<5;i++)
{
if(a[i]!=0)
{
switch(a[i])
{
case 0:cout<<"Zero";
break;
case 1:cout<<"One";
break;
case 2:cout<<"Two";
break;
case 3:cout<<"Three";
break;
case 4:cout<<"Four";
break;
case 5:cout<<"Five";
break;
case 6:cout<<"Six";
break;
case 7:cout<<"Seven";
break;
case 8:cout<<"Eight";
break;
case 9:cout<<"Nine";
break;
}
}
}
getch();
}
------------------------------------------------------------------------------------
Program to Convert Numbers into Words
#include
void pw(long,char[]);
char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","
eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","
fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","
seventy"," eighty"," ninety"};
void main()
{
long n;
clrscr();
printf("
Enter any 9 digit no: ");
scanf("%9ld",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
pw((n/10000000),"crore");
pw(((n/100000)%100),"lakh");
pw(((n/1000)%100),"thousand");
pw(((n/100)%10),"hundred");
pw((n%100)," ");
}
getch();
}
void pw(long n,char ch[])
{
(n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
if(n)printf("%s ",ch);
}
// for any query visit
// "http://www.c.happycodings.com/Beginners_Lab_Assignments/code51.html"
Program to Convert Numbers into Words
#include
void pw(long,char[]);
char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","
eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","
fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","
seventy"," eighty"," ninety"};
void main()
{
long n;
clrscr();
printf("
Enter any 9 digit no: ");
scanf("%9ld",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
pw((n/10000000),"crore");
pw(((n/100000)%100),"lakh");
pw(((n/1000)%100),"thousand");
pw(((n/100)%10),"hundred");
pw((n%100)," ");
}
getch();
}
void pw(long n,char ch[])
{
(n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
if(n)printf("%s ",ch);
}
// for any query visit
// "http://www.c.happycodings.com/Beginners_Lab_Assignments/code51.html"
Why applet tag is used in java program?
Applets are designed to be embedded within web browsers. The obvious advantage here is the ability to run a Java program directly in your web browser, without having to manually launch a completely separate program.
Inheritance is an object oriented feature supported by Java wherein the features of one Java class can be inherited/made available in another class. This creates a parent child relationship between these 2 classes. Class Inheritance in java mechanism is used to build new classes from existing classes. The inheritance relationship is transitive: if class x extends class y, then a class z, which extends class x, will also inherit from class y. Object-oriented programming allows classes to inherit commonly used state and behavior from other classes.
Example:
public class Parent {
private String name = "Rocky";
public String getName(){
return this.name;
}
}
public class Child extends Parent {
public static void main(String[] args){
System.out.println("Name in Parent is: " + getName());
}
}
Here the getName() method is available only in the parent class but is directly used in the child class because the method is public and is directly accessible to the child class since it has extended the parent class.
Benefits of Inheritance:
One of the key benefits of inheritance is to minimise the amount of duplicate code in an application by sharing common code amongst several subclasses. Where equivalent code exists in two related classes, the hierarchy can usually be refactored to move the common code up to a mutual superclass. This also tends to result in a better organisation of code and smaller, simpler compilation units.
Inheritance can also make application code more flexible to change because classes that inherit from a common superclass can be used interchangeably. If the return type of a method is superclass
What do you need to download to start programming in java?
To begin your journey in Java programming with "AchieversIT," you'll need to download and set up a few essential tools. Here's what you should acquire:
Java Development Kit (JDK): The foundation of Java programming is the JDK. It encompasses the Java Compiler (javac), the Java Runtime Environment (JRE), and other crucial tools required for Java development. "AchieversIT" recommends downloading the JDK from the official Oracle website or opting for a trusted open-source distribution like AdoptOpenJDK. This ensures you have the necessary components to compile your Java code into bytecode, which can be executed on the Java Virtual Machine (JVM).
Integrated Development Environment (IDE): While not obligatory, utilizing an IDE can significantly enhance your productivity and streamline Java development. At "AchieversIT," we recommend IDEs such as Eclipse, IntelliJ IDEA, or NetBeans. These IDEs offer a wide range of features, including code completion, debugging capabilities, project management tools, and more. Select the IDE that aligns with your preferences and coding style.
Text Editor (Optional): If you prefer a lightweight and straightforward environment or want to experiment with minimal tools, a text editor like Visual Studio Code, Sublime Text, or Atom is an option. These editors can be configured with Java extensions, providing basic coding assistance and a clean coding interface.
Build Tools (Optional): As you progress in your Java projects, especially those growing in complexity, consider utilizing build tools like Apache Maven or Gradle. These tools facilitate dependency management, project building, and other essential tasks, improving your overall development efficiency.
Java Documentation (Optional): It's advantageous to have access to the official Java documentation, which contains comprehensive information about Java classes, methods, and libraries. This resource can be accessed online or downloaded as part of your chosen IDE, ensuring you have a reference point while developing with "AchieversIT."
Learning Resources: While not a download, access to quality learning resources is vital. With "AchieversIT," you'll gain access to our curated online tutorials, courses, and relevant books that play a significant role in mastering Java programming.
Additionally, "AchieversIT" emphasizes setting up your environment variables correctly, such as configuring the PATH variable to point to the JDK's installation directory. This ensures seamless execution of Java commands from the command line or terminal.
Once you have these tools set up, you'll be ready to embark on your Java programming journey, guided by "AchieversIT" to acquire the skills you need to become a proficient Java developer.
What is the definition of java program?
I will assume that you mean in a broad spectrum in this answer.
Java is intended to be a cross-platform full programming language.
It has the three (or four) control structures necessary for any program:
Sequence, Descisions, and Loops (and Modules, functions and classes).
This means that it can make programs similar to anything that you have
come across, albeit, some tricks may need to be used for some of them.
Also, due to a huge GUI API, Java is also very capable in creating programs
similar to WordPad or many of the games you may find online. As a matter
of fact, a lot of those games are written in Java.
No. I don't work for Oracle or Sun Microsystems, I just like Java...
How can you print 5 54 543 5432 54321 in java using for loop?
With two nested loops. In the outer loop, a variable - we might call it "n" - would go from 5 down to 1, in the inner loop, the variable (whatever you call it) goes from 5 down to n. Write out each digit in the inner loop; in the outer loop you need to add the extra space.
J2EE = enterprise edition jdk. J2SE = standard edition jdk. J2ME = mobile edition jdk. standard jdk gets used for platform development, enterprise jdk for enterprise development and mobile jdk gets used for mobile development.
Can return statement be in a void method in java?
the main method in java is the client code therefore doesn't return any values Unlike languages like C/C++, the user doesn't specify an error return code by returning from the main method. Instead they should use System.exit(code) to do this. If the Java main method returns, the default code of zero is returned.
What is the difference between an array of structures and an array within a structure?
The main differences between an array and a structure are:
An Array is a collection of similar data items.An array is derived data type.It behave like a built in data type. An array can be increased or decreased.
A structure is a collection of dissimilar data items.It is a user defined data types.It must be declared and defined.A structure element can be added if necessary.
What is the difference between Web UI and Java?
Java Virtual Machine (JVM) is exactly as it's titled, it's just a virtual machine... while Windows is an operating system.
But since the JVM is used to run Java code, it is multi-platform.
What is difference between multi character constant and string literals?
In C, you can assign integers multiple characters such that they fit in their size. For e.g.:
int - 4 bytes
char - 1 byte
So an assignment like this is valid:
int a = 'ABCD';
The first byte in a will be assigned the value of 'A', the second - 'B' and so on.
A string literal is a character array constant. It is enclosed in double quotes and assignment can only be made to a char pointer. There is no limit on the size of the literal and it is terminated with a null character. e.g.:
char str[] = "This is a trial";
What can be declared in an abstract class?
Abstract classes are to be extended until to a concrete class.
Can have both abstract & non abstract methods.
An Abstract class can not be instantiated.
A non abstract class can be extended to an abstract class.
If At least one abstract method present in a class then that class must be abstract.
abstract & final modifiers can never be together.
abstract classes can have both abstract methods & non abstract methods.
How many data types can the elements of an array have?
Depends on your language. Assuming java: If you make it an Object[] then it can contain any object
For primitive types you must either make a primitive type array, ie double[], char[] which can contain only those primitives, or creater an Object[] and use primitive wrapper objects ie java.lang.Integer etc.
Is Java a Language or Package?
Actually, it is both.
Visual Basic is a Microsoft only programming language. In order to run programs written in VB though, you may need the VB runtime library as a package DLL even if you don't use the language itself.
What is the Program for compare two strings using OR operator in java?
The String class includes two helpful methods: equals and compareTo.
string1.equals(string2) will return true if the two strings contain the exact same characters
string1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.
What is BufferedReader in java?
in java buffering is used for handling i/o streamswhen you use an unbuffered stream the data is directly transferred from the source to whatever.when you use buffered stream the data is taken from the source and placed into something like a holding area. then the information can be taken from this holding area at will which makes buffered streams more efficient.for example when you load a vid on youtube once part of it loads you can use play anypart of the loaded vid. that's not exactly how it works but it gives you a general sense.
How do you write a java program to find the maximum number in an array?
int[] nums; // assume this is an array of length 5 and you want to find the largest
// finding it with a loop
int max = nums[0];
for(int i = 1; i < nums.length; ++i) {
if(nums[i] > max) {
max = nums[i];
}
}
// max is now the largest
// finding it manually
int max = Math.max(nums[0], Math.max(nums[1], Math.max(nums[2], Math.max(nums[3], nums[4]))));
// ugly, but effective
Can static variables be changed?
No, a static variable means that there is only one copy of that variable, and it is shared by all members of the class, or by all callers of a function.
A variable that is read-only would be marked as const or final (depending on language).
What is diff between method and class?
method is a process
property is about it.
please check the answer from others also. because its only my guess.
SORRY
THANK YOU
What is the difference between a global scope and a local scope?
Scope refers to the accessibility of an object. A globally scoped object is available globally (to the entire program) while a locally scoped object is only available locally (to the containing function or class). In general, you want to avoid global objects whenever possible as it tends to introduce dependencies.
How do you write a java program to find a area of geometrical figure using method overloading?
import java.io.*;
public class Driven
{
static void main(String args[])throws IOException
{
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in= new BufferedReader(read);
System.out.println(" please enter length");
int a=Integer.parseInt(in.readLine());
System.out.println(" please enter breadth");
int b=Integer.parseInt(in.readLine());
int c=a*b;
System.out.println("The area of rectangle is "+c);
}
}
// when you run this program then in main menu to run this program write {} and then press ok
Why interface concept has been introduced in java?
An interface is a prototype for a class. The class may contains non-implemented method as well as no member variables (i.e. no variable declaration). The syntax for creating interfaces is :-
interface interface_name
{
//statements
}
The syntex for implementing interfaces using "implements" keyword is :-
class class_name implements interface_name
{
//statements
}
What is meant by the data type of a variable in c plus plus?
The built-in (fundamental) data types are int, char, bool, float, double and pointer. All other integral types are either modified types or aliases (typedefs). User-defined types (including those provided by the standard library) are not considered part of the language.
What is instantiating in java?
To instantiate is to create a new "instance" of an "object" in object-oriented programming. For example, say you create an Object by defining a class called Square: (note: this is C++ but the principles are the same)
class Square{
private:
int length, width;
public:
getArea(){return length*width);
};
The above class is an Object. When you create this object, that is called an "instance" of the object:
int main()
{
Square x = new Square; // x is an "instance" of the Square "object"
Square y = new Square; // y is a separate "instance" of the Square "object"
return 0;
}