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

Polity

  1.    सन 1600 में ईस्ट इंडिया कंपनी भारत आई थी जिसका परमिशन ब्रिटिश की महारानी एलीजाबेथ ने दिया था 2.    परमिशन में चार्टर दिया गया था साथ ही मोनोपोली दी गयी थी अलीजाबेत के द्वारा 3.    बिटिश ईष्ट इंडिया कंपनी भारत शिप से आई थी जिस शिप का नाम था रेड ड्रैगन 4.    भारत में आने के बाद उन्होंने पहली फैक्ट्री 1611 मछलीपटनम में बनाई 5.    दूसरी फैक्ट्री 1612 में सूरत में बनाया था 6.    फैक्ट्री नियन्त्र के लिए तीन प्रेसीडेंसी बनायीं गयी जो थी बॉम्बे, बंगाल, मद्रास 7.    बंगाल का राजा था सिराजुदुल्ला और ब्रिटिश रोबर्ट clive युद्ध किया 1757 ऐसा जिसे battle of plasi कहा गया जिसमें रोबर्ट clive की जीत हुयी 8.    कंपनी का rule 1773 से 1858 तक चला था 9.    ताज का शाशन था 1858 से 1947 10.    Regulating act आया था 1773 में 11.    Act of settlement आया था 1781 में 12.    भारत परिषद् अधिनियम आया था 1861, 1892, 1909 13.    Govt of इंडिया act आया था 1858 में 14.                  ब्रिटिश सरकार ने 1773 में एक regulating act लाया गया जिसमें बंगाल को हेड बनाया गया जिसे गवर्नर जनरल कहा गया बंगा

Linked List Data Structure

Question: How to create without generic Int type Node ? Ans:  public class Node { // this is Node class without Generic int data ; // this is for data like array Element Node next ; //Node ek class hai , usi class ka khud ka variable hai, This is Node(Class) Type variable for //Node is basically refer to class , this is for next element Node ( int data ){ // this is constructor bcse user will pass data value and int because we want to create int type data constructor this . data = data ; // this is refer data next = null ; } }  

Test 2

 Question: You have made a smartphone app and want to set its subscription price such that the profit earned is maximised. There are certain users who will subscribe to your app only if their budget is greater than or equal to your price. You will be provided with a list of size N having budgets of subscribers and you need to return the maximum profit that you can earn. Lets say you decide that price of your app is Rs. x and there are N number of subscribers. So maximum profit you can earn is : m*x Sample input 1: 30 20 53 14 Output 60 import   java . util .*; import   java . util . Scanner ; public   class   solution   {      public   static   int   maximumProfit ( int   budget [])   {      Arrays . sort ( budget );          // int maxProfit = 0;          // // Iterate through each possible subscription price and calculate profit          // for (int i = 0; i < budget.length; i++) {          //     int currentProfit = budget[i] * (budget.length - i);          //     maxProfit = Mat