Skip to main content

C Programming for Beginners #2 (First Program hello world)




  • This is the First C Program from which every programmer have started.
#include<stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}

Explanation of the Program
  1. include is to add the specific library to compile the program.
  2. In this case stdio.h is the library in which commands are predefined it is called as preprocessor directive.
  3. printf is used when we have to display something on screen.
  4. In printf \n is used to print on the new line.
  5. After every end of command ; is used.
To compile the C program there are many compilers available but if you ask me I compile and run my programs on ubuntu so in ubuntu the program is typed in text editor and saved it as .c file and in terminal it is compiled by two ways using gcc name.c and in place of name you have to enter the name of file you have saved.

It will give the compiled program as a.out and you can run it by ./a.out command

Note:- To give your program the name you want instead of gcc you can use make name command to compile your program.

Comments

Popular posts from this blog

Android O (Android Operating system)

There are many kind of changes and improvements in this new version of Android OS. Increased Ability of the mobile:- aptX bluetooth streaming :-   High quality audio codec is supported for streaming to bluetooth Headsets and Speakers Adaptive icons give devs and OEMs easy shape masks, extra effects :-  "an OEM like Samsung or HTC will provide a unifying mask, which will allow developers to integrate almost any existing app icon into the broader user interface with minimal effort, and no extra graphics work on the icon itself." Neighborhood Aware Networking (NAN) mode for WiFi :-  "You can think about NAN as a combination of WiFi Direct and Nearby. Two hypothetical phones with NAN could find each other and connect without any additional apps or configuration, allowing them to share data at high speeds." Picture-in-picture video for all devices and new windowing features :- "The gist is that when watching video on Android O, you'll be able to shr...

Artificial Intelligence

Artificial Intelligence (AI) in Engineering Artificial Intelligence (AI) is the science of using a computer (program) to help think of solutions to solve a particular problem. This is especially very useful in the field of Engineering; due to the need of constantly trying to automate every process for improved efficiency. Every engineering field has benefitted from the use of AI, some more than others. Computer Engineering Computer Engineering is the primary field in which AI is used. Many companies are preferring AI programming over traditional programming as it allows their programs to be long lasting and avoids the constant need to update. Personal Assistant applications like Google Now, Siri and cortana heavily rely on the use of AI for predicting user behavior and voice recognition. Other application include video games, Purchase prediction, Smart cars, Fraud detection, Security services etc. Instrumentation Engineering Instrumentation Engineering primar...

C Programming #6 (Loop Control Instruction)

In C Programming if we want to repeat some statements here we make the use of loops. There are three methods by which we can repeat part of program. Using for statement Using a while statement Using a do-while statement The while loop: It will repeat the program until the condition in while loop become false. Example: /*Calculation of simple interest for 3 sets of p, n and r*/ #include<stdio.h> int main() { int p,n,count; float r,si; count=1; while(count<=3) { printf("\nEnter values of p,n and r"); scanf("%d%d%f",&p,&n,&r); si=p*n*r/100; printf("Simple interest = Rs. %\nf",si); count=count+1; } return 0; } Here this program while loop has the condition to repeat the program 3 times. As in while loop at the end count is increased by 1 every time it execute and when it reaches to 3 control comes out of program and the program terminates. Tips and Traps As I mentioned in m...