You are on page 1of 5

conditions for C programming 1- we must include stdio.h header file #include<stdio.h> -- include for lib dir #include "stdio.

h" -- include from any where. 2- program always start with void main function void main() - without command line arguments void main(int argc,char *argv[]) - with command line arguments command line arguments - pass with command dos copy aa.txt aa1.txt - aa & aa1.txt both r the command line arguments for copy command. argc - argument count argv - argument values // to wor with command line arguments in C, display welcome msg for all #include<stdio.h> -- include for lib dir void main(int argc,char *argv[]) - with command line arguments { int i; clrscr(); for(i=0;i<argc;i++) printf("Welcome %-12s\n",argv[i]); getch(); } save with Wel.c ctrl + f9 - run without command line arguments dos c:\tc\bin>Wel Amit jai Ajai Kalu Babu Ramu argv[0] 1 2 3 4 5 6 in java c:\>java Wel Amit jai Ajai Kalu Babu Ramu argv[0] 1 2 3 4 5 Q- diff b/w C, C++ & java command line arguments Ans - in C & C++ - 1st element - file name(0th index) in java - 1st element - 1st argument (0th index) 3- all declaration b/f calling any function int a,b,c; clrscr(); - for clear the screen printf("") - for console output scanf() - for console input getch(); - get any char for eyword.

Q- what is the return type of printf() & scanf() ? ans- printf() - return number of chars. scanf() - return number of inputs int x,a; x = printf("Welcome"); x = 7 x = scanf("%d",&a); x = 1 user input - 1000

Q- how to display welcome msg in C without using ; Ans- yes can display with if void main() { if(printf("Welcome's U")){} } bcos conditions in C & C++ - if(0 for false excluding 0 true) while(1) - in C & C++ / while(true) - java & .Net

Q- how to call function in C before & after main? Ans- yes can call with the help of pragma pre processor. #pragma startup funname #pragma exit funname ** function always without any argument hoga. Q- how to design window in C & C++ without using Graphics? Ans - can draw with ascii code C & C++ support - 256 charset only. 0 - 255 , 65 - A , 97 - a alt + num ey(200) & release alt ey Q- what is the live example of doubly lin ed list? Ans- Browser bac & forward + undo & redo in ms word. Q- live example of BST? Ans - indexes in databases & OS ---------------------------------------------------------------------// to create simple program in java, just display welcome msg? class Wel { public static void main(String args[]) -- li e main in C & C++ { System.out.println("Welcome's U"); // li e printf() in C & cout in C++ } } save with Wel.java

getche(); - get any char for

eyword & display on console window.

javac Wel.java - for compile java Wel - for Run conditions for java programming 1- class name & file name must be same, if class not public then we can save with other name also. but if class is public then always save with that name only. Access modifiers in C++ prop * access in same class * Access in sub class * Access in non sub class private protected public Y Y Y N Y Y N N Y

protected data members can access in sub class, but not access in non sub class ** default access modifier in C++ class is - private, but in struture default access modifier is - public sub class - when one class inherit with another class Live example - parent & child relations. non sub class - when one class object created inside another class Live example - Landlord & rent person Person - A CC - private A/C - protected Mobile - public B is the child of A - Sub class of A CC - Not access A/C - Access Mobile - Access C is the Rent person for A - non sub of A CC - Not access A/C - Not Access Mobile - Access - implementation class A { int cc; - with private modifier protected : int ac; - with protected modifier public : int mobile; - with public modifier private : int dc; - with private modifier. };

Access modifiers in Java * * * * * prop access in same class sub class of same pac non sub class of same sub class of diff pac non sub class of diff private default protected public Y Y Y Y N Y Y Y age N Y Y Y N N Y Y age N N N Y

protected data members can access in sub class of another pac age, but not access in non sub class of another pac age. pac age - it is a container that contain the class files, interfaces & sub pac ages. or it is a ind of folder that contain the class files, interfaces & sub folders. or pac ages r li e header files in C & C++. Adv - pac ages r used for implement the modular approaches. * * * * * Simplicity Reusability Performence Improve error handling & debugging easy. Securities - Modifier

Imp. points - always with U. * default access modifier in java is - default. -> class + class members + interface modifier - default is default. class A {} - with default access modifier interface A {} - with default access modifier class A { int x; - with default access modifier } -> default Constructor + interface members modifier - default with public mo difier interface A { int x = 10; - default with public modifier. void disp(); - default with public modifier. } -> class can't be private & protected. private class A{} - error, modifier private not allowed here. protected class A{} - error, modifier protected not allowed here. -> class only - default or public. default - within pac age access public -inside/outside pac age access - any where. ** outer class can't be private + protected + static.

age pac age pac

-> now Wel is the no public class then we can save with other name also. may be A.java + B.java + C.java javac A.java - compile with file name java Wel - run with class name, bcos class file created with classname

You might also like