Skip to main content

Basics of Programming In C || Sesion 1 & 2




1) About Variables In programming C.
Ans:

What is Variable: C programming me, "variables" wo placeholders hote hain jahan par aap data store karte hain. In variables me aap numeric values, characters, strings, aur doosre data ko store kar sakte hain. Variables ke use se aap program me data ko manipulate aur process kar sakte hain.

  • In Simple term Variable kisi v container ka rkha gya name hota hai, Suppose ham apne gharo me Sugar, Masale etc steel ke container me store kar rhe hai aur uske upar ek label lga rhe us label me hamne sugar likh diya to ab ye label jisme sugar likha hai wo likha hua name programming ki terms me Variable kehlata hai . 
  • U can say variable is the name of a Memory.


C programming me, aap variables ko declare karte hain, jisme aap unka data type aur naam specify karte hain. Kuch common data types hain:


1. `int`: Integer values (pooray numbers) ko store karne ke liye, jaise `int age = 25;`.


2. `float`: Floating-point values (decimal numbers) ko store karne ke liye, jaise `float price = 19.99;`.


3. `char`: Single characters ko store karne ke liye, jaise `char grade = 'A';`.


4. `double`: Double-precision floating-point numbers ko store karne ke liye, jaise `double salary = 50000.75;`.


5. `char[]` ya `char*`: Strings ko store karne ke liye, jaise `char name[] = "John";` ya `char* name = "John";`.


2) Rules of Variables in Java .
Ans:

  • Case Sensitivity: C programming me variable names case-sensitive hote hain, yani ki "myVariable" aur "myvariable" alag-alag variables hote hain.
  • Variable Name (Naam): Variable ka naam alphabets (a-z, A-Z) se shuru hona chahiye ya underscore (_) se shuru ho sakta hai. Aap numbers (0-9) ka istemal variable naam ke beech me kar sakte hain, lekin variable ka naam number se shuru nahi ho sakta. Variable naam me koi special character (jaise @, $, %, etc.) istemal nahi kiya ja sakta hai.
  • Reserved Words: Aap reserved words (jaise int, float, for, while, if, aadi) ko variable naam ke roop me istemal nahi kar sakte hain.
  • Data Type: Variable ka naam data type ke sath match karna chahiye. For example, ek integer variable ko "intCount" jaisa naam dena behtar hai.



3) what is Keywords in Programming c ?
Ans: C programming me, keywords ya reserved words special words hote hain jo programming language me predefined hoti hain aur specific tasks ko perform karti hain. Ye words aapko apne program me variable names ya function names ke roop me use nahi karne chahiye, kyunki ye pehle se define ki gayi hain aur inka specific meaning hota hai. Kuch common C programming keywords hain:

1. `auto`: Variable ko automatic storage class mein declare karne ke liye.

2. `break`: Loop ko todkar bahar nikalne ke liye.

3. `case`: Switch statement ke case ke liye.

4. `char`: Character data type ke liye.

5. `const`: Constant value ko declare karne ke liye.

6. `continue`: Loop ki current iteration ko chhodkar next iteration me jana ke liye.

7. `default`: Switch statement ke default case ke liye.

8. `do`: Loop ki shuruaat me ek block of code ko execute karne ke liye.

9. `double`: Double-precision floating-point data type ke liye.

10. `else`: If statement ke alternative block of code ke liye.

11. `enum`: Enumeration type define karne ke liye.

12. `extern`: External variable declare karne ke liye.

13. `float`: Floating-point data type ke liye.

14. `for`: Loop ke liye.

15. `goto`: Code me specific label par jana ke liye.

16. `if`: Conditional statement ke liye.

17. `int`: Integer data type ke liye.

18. `long`: Long integer data type ke liye.

19. `register`: Register storage class mein variable declare karne ke liye.

20. `return`: Function se value return karne ke liye.

21. `short`: Short integer data type ke liye.

22. `signed`: Signed data type specifier.

23. `sizeof`: Variable ya data type ki size (bytes) nikalne ke liye.

24. `static`: Static storage class mein variable declare karne ke liye.

25. `struct`: User-defined structure define karne ke liye.

26. `switch`: Multi-way decision making ke liye.

27. `typedef`: New data type define karne ke liye.

28. `union`: Union data type define karne ke liye.

29. `unsigned`: Unsigned data type specifier.

30. `void`: Kuch nahi (return type undefined) ke liye.

31. `volatile`: Variable ka value kabhi bhi badal sakta hai, isiliye compiler optimization ke liye ignore nahi kiya jata

32. `while`: Loop ke liye.

In keywords ka istemal program structure, decision making, loops, data types, functions, aur storage classes ke liye hota hai. Aap in keywords ka istemal apne C program me karte hain taki aap code ko define aur control kar saken.


3) Program Structure of C.
Ans: 


4) How to write Comments in Programming  ?
Ans: for single line u can use this forward slash

u have to write 2 times like this //
// a = 20; //Line 1

if u want to comments in multiple line u have to use /* and *\



Comments

Popular posts from this blog

Block vs Inline Elements In HTML

  Block: Block element always start in New Line  Block element always start in new line occupy complete width available  Example: h2, p, div Inline Element: They do not start in new line occuply width as much required  Example: img, anchor a,span There are no different between div and span, only difference is div is block element and span is Inline, it will help you to group your content or elements

Time Complexity

What is time complexity ? Ans: Time complexity not a run time of a code, its totally depends on system configuration, processor, server , input size will increase time complexity. Time complexity ko likhne ke tarike jo hote hai use notation kehte hai. Notation is basically symbol NOTATION OF COMPLEXITY Best Case: kam se kam time me chla gya code best case hota hai Ω (Omega) Ω(1) se likhte hai Average Case: Ek average time jisme code chle  Θ(n+1)/2 Worst Case: Worst case ka mtlb kuch bhi ho jaye is time ko ye exceed nhi kregea O(n) Nested Loop me Time Complexity multiply hoti hai aur n^2 banti hai Wahi Do different loops me N+M hoti hai jisme jiski sabse bdi value hai wo big of O me jati hai O(1) - Constant Time: Operations that take a constant amount of time, regardless of the size of the input data. O(log n) - Logarithmic Time: Algorithms that have a logarithmic time complexity, often seen in binary search or certain tree-based algorithms. This is best time Complexity this i...

Find Unique Number in Array Java , XOR

 Question:  WAP to find unique number in Array Java package aRray ; import java . util .*; public class practicalArray { public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ) ; // Step 1: Input size of the array from the user int size = scan . nextInt () ; // Step 2: Create an integer array of the specified size int [] arr = new int [ size ] ; // Step 3: Initialize 'res' with the first element of the array int res = arr [ 0 ] ; // Step 4: Loop to read array elements and find the unique number for ( int i = 1 ; i < size ; i ++ ) { // Read an integer from the user and store it in the array arr [ i ] = scan . nextInt () ; // Step 5: Use XOR (^) operation to find the unique number res = res ^ arr [ i ] ; } // Step 6: Print the unique number System . out . print...